Convert all tests to ESM

environments/review-test-esm-a3vqn6/deployments/4109
Alex Gleason 2023-10-08 22:18:34 -05:00
rodzic f8c87a4594
commit 34131cdfcc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
21 zmienionych plików z 192 dodań i 176 usunięć

Wyświetl plik

@ -98,8 +98,8 @@ describe('fetchAccount()', () => {
});
});
describe('with a successful API request', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
describe('with a successful API request', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
beforeEach(() => {
const state = rootState;

Wyświetl plik

@ -1,5 +1,6 @@
import { List as ImmutableList } from 'immutable';
import announcements from 'soapbox/__fixtures__/announcements.json';
import { fetchAnnouncements, dismissAnnouncement, addReaction, removeReaction } from 'soapbox/actions/announcements';
import { __stub } from 'soapbox/api';
import { buildInstance } from 'soapbox/jest/factory';
@ -8,8 +9,6 @@ import { normalizeAnnouncement } from 'soapbox/normalizers';
import type { APIEntity } from 'soapbox/types/entities';
const announcements = require('soapbox/__fixtures__/announcements.json');
describe('fetchAnnouncements()', () => {
describe('with a successful API request', () => {
it('should fetch announcements from the API', async() => {

Wyświetl plik

@ -35,8 +35,8 @@ describe('fetchBlocks()', () => {
});
describe('with a successful API request', () => {
beforeEach(() => {
const blocks = require('soapbox/__fixtures__/blocks.json');
beforeEach(async () => {
const blocks = await import('soapbox/__fixtures__/blocks.json');
__stub((mock) => {
mock.onGet('/api/v1/blocks').reply(200, blocks, {
@ -132,8 +132,8 @@ describe('expandBlocks()', () => {
});
describe('with a successful API request', () => {
beforeEach(() => {
const blocks = require('soapbox/__fixtures__/blocks.json');
beforeEach(async () => {
const blocks = await import('soapbox/__fixtures__/blocks.json');
__stub((mock) => {
mock.onGet('example').reply(200, blocks, {

Wyświetl plik

@ -11,8 +11,8 @@ import {
} from './preload';
describe('preloadMastodon()', () => {
it('creates the expected actions', () => {
const data = require('soapbox/__fixtures__/mastodon_initial_state.json');
it('creates the expected actions', async () => {
const data = await import('soapbox/__fixtures__/mastodon_initial_state.json');
__stub(mock => {
mock.onGet('/api/v1/accounts/verify_credentials')

Wyświetl plik

@ -5,7 +5,7 @@ import { fetchRules, RULES_FETCH_REQUEST, RULES_FETCH_SUCCESS } from './rules';
describe('fetchRules()', () => {
it('sets the rules', async () => {
const rules = require('soapbox/__fixtures__/rules.json');
const rules = await import('soapbox/__fixtures__/rules.json');
__stub((mock) => {
mock.onGet('/api/v1/instance/rules').reply(200, rules);

Wyświetl plik

@ -31,8 +31,8 @@ describe('fetchStatusQuotes()', () => {
});
describe('with a successful API request', () => {
beforeEach(() => {
const quotes = require('soapbox/__fixtures__/status-quotes.json');
beforeEach(async () => {
const quotes = await import('soapbox/__fixtures__/status-quotes.json');
__stub((mock) => {
mock.onGet(`/api/v1/pleroma/statuses/${statusId}/quotes`).reply(200, quotes, {
@ -103,8 +103,8 @@ describe('expandStatusQuotes()', () => {
});
describe('with a successful API request', () => {
beforeEach(() => {
const quotes = require('soapbox/__fixtures__/status-quotes.json');
beforeEach(async () => {
const quotes = await import('soapbox/__fixtures__/status-quotes.json');
__stub((mock) => {
mock.onGet('example').reply(200, quotes, {

Wyświetl plik

@ -9,7 +9,7 @@ import { deleteStatus, fetchContext } from './statuses';
describe('fetchContext()', () => {
it('handles Mitra context', async () => {
const statuses = require('soapbox/__fixtures__/mitra-context.json');
const statuses = await import('soapbox/__fixtures__/mitra-context.json');
__stub(mock => {
mock.onGet('/api/v1/statuses/017ed505-5926-392f-256a-f86d5075df70/context')
@ -60,8 +60,8 @@ describe('deleteStatus()', () => {
describe('with a successful API request', () => {
let status: any;
beforeEach(() => {
status = require('soapbox/__fixtures__/pleroma-status-deleted.json');
beforeEach(async () => {
status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
__stub((mock) => {
mock.onDelete(`/api/v1/statuses/${statusId}`).reply(200, status);

Wyświetl plik

@ -1,3 +1,4 @@
import IconCode from '@tabler/icons/code.svg';
import React from 'react';
import { render, screen } from 'soapbox/jest/test-helpers';
@ -5,8 +6,8 @@ import { render, screen } from 'soapbox/jest/test-helpers';
import SvgIcon from './svg-icon';
describe('<SvgIcon />', () => {
it('renders loading element with default size', () => {
render(<SvgIcon className='text-primary-500' src={require('@tabler/icons/code.svg')} />);
it('renders loading element with default size', async () => {
render(<SvgIcon className='text-primary-500' src={IconCode} />);
const svg = screen.getByTestId('svg-icon-loader');
expect(svg.getAttribute('width')).toBe('24');

Wyświetl plik

@ -19,8 +19,8 @@ const normalize = (notification: any) => {
};
describe('<Notification />', () => {
it('renders a follow notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-follow.json'));
it('renders a follow notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-follow.json'));
render(<Notification notification={notification} />, undefined, state);
@ -30,9 +30,9 @@ describe('<Notification />', () => {
});
describe('grouped notifications', () => {
it('renders a grouped follow notification for more than 2', async() => {
it('renders a grouped follow notification for more than 2', async () => {
const { notification, state } = normalize({
...require('soapbox/__fixtures__/notification-follow.json'),
...await import('soapbox/__fixtures__/notification-follow.json'),
total_count: 5,
});
@ -43,9 +43,9 @@ describe('<Notification />', () => {
expect(screen.getByTestId('message')).toHaveTextContent('Nekobit + 4 others followed you');
});
it('renders a grouped follow notification for 1', async() => {
it('renders a grouped follow notification for 1', async () => {
const { notification, state } = normalize({
...require('soapbox/__fixtures__/notification-follow.json'),
...await import('soapbox/__fixtures__/notification-follow.json'),
total_count: 2,
});
@ -57,8 +57,8 @@ describe('<Notification />', () => {
});
});
it('renders a favourite notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-favourite.json'));
it('renders a favourite notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-favourite.json'));
render(<Notification notification={notification} />, undefined, state);
@ -66,8 +66,8 @@ describe('<Notification />', () => {
expect(screen.getByTestId('status')).toContainHTML('https://media.gleasonator.com');
});
// it('renders a follow_request notification', async() => {
// const { notification, state } = normalize(require('soapbox/__fixtures__/notification-follow_request.json'));
// it('renders a follow_request notification', async () => {
// const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-follow_request.json'));
// render(<Notification notification={notification} />, undefined, state);
@ -75,8 +75,8 @@ describe('<Notification />', () => {
// expect(screen.getByTestId('account')).toContainHTML('alex@spinster.xyz');
// });
it('renders a mention notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-mention.json'));
it('renders a mention notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-mention.json'));
render(<Notification notification={notification} />, undefined, state);
@ -84,8 +84,8 @@ describe('<Notification />', () => {
expect(screen.getByTestId('status')).toContainHTML('ActivityPub spec');
});
it('renders a move notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-move.json'));
it('renders a move notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-move.json'));
render(<Notification notification={notification} />, undefined, state);
@ -93,8 +93,8 @@ describe('<Notification />', () => {
expect(screen.getByTestId('account')).toContainHTML('benis911');
});
it('renders a pleroma:emoji_reaction notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-pleroma-emoji_reaction.json'));
it('renders a pleroma:emoji_reaction notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-pleroma-emoji_reaction.json'));
render(<Notification notification={notification} />, undefined, state);
@ -102,16 +102,16 @@ describe('<Notification />', () => {
expect(screen.getByTestId('status')).toContainHTML('Super Mario 64');
});
it('renders a pleroma:chat_mention notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-pleroma-chat_mention.json'));
it('renders a pleroma:chat_mention notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-pleroma-chat_mention.json'));
render(<Notification notification={notification} />, undefined, state);
expect(screen.getByTestId('notification')).toContainHTML('dave');
});
it('renders a poll notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-poll.json'));
it('renders a poll notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-poll.json'));
render(<Notification notification={notification} />, undefined, state);
@ -119,8 +119,8 @@ describe('<Notification />', () => {
expect(screen.getByTestId('status')).toContainHTML('what do you guys think?');
});
it('renders a reblog notification', async() => {
const { notification, state } = normalize(require('soapbox/__fixtures__/notification-reblog.json'));
it('renders a reblog notification', async () => {
const { notification, state } = normalize(await import('soapbox/__fixtures__/notification-reblog.json'));
render(<Notification notification={notification} />, undefined, state);

Wyświetl plik

@ -1,9 +1,9 @@
import { Record as ImmutableRecord, fromJS } from 'immutable';
import { normalizeAccount } from './account';
import AVATAR_MISSING from 'soapbox/assets/images/avatar-missing.png';
import HEADER_MISSING from 'soapbox/assets/images/header-missing.png';
const AVATAR_MISSING = require('soapbox/assets/images/avatar-missing.png');
const HEADER_MISSING = require('soapbox/assets/images/header-missing.png');
import { normalizeAccount } from './account';
describe('normalizeAccount()', () => {
it('adds base fields', () => {
@ -33,29 +33,29 @@ describe('normalizeAccount()', () => {
expect(result.verified).toBe(false);
});
it('normalizes Fedibird birthday', () => {
const account = require('soapbox/__fixtures__/fedibird-account.json');
it('normalizes Fedibird birthday', async () => {
const account = await import('soapbox/__fixtures__/fedibird-account.json');
const result = normalizeAccount(account);
expect(result.birthday).toEqual('1993-07-03');
});
it('normalizes Pleroma birthday', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
it('normalizes Pleroma birthday', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
const result = normalizeAccount(account);
expect(result.birthday).toEqual('1993-07-03');
});
it('normalizes undefined birthday to empty string', () => {
const account = require('soapbox/__fixtures__/mastodon-account.json');
it('normalizes undefined birthday to empty string', async () => {
const account = await import('soapbox/__fixtures__/mastodon-account.json');
const result = normalizeAccount(account);
expect(result.birthday).toEqual('');
});
it('normalizes Pleroma legacy fields', () => {
const account = require('soapbox/__fixtures__/pleroma-2.2.2-account.json');
it('normalizes Pleroma legacy fields', async () => {
const account = await import('soapbox/__fixtures__/pleroma-2.2.2-account.json');
const result = normalizeAccount(account);
expect(result.getIn(['pleroma', 'is_active'])).toBe(true);
@ -65,8 +65,8 @@ describe('normalizeAccount()', () => {
expect(result.hasIn(['pleroma', 'confirmation_pending'])).toBe(false);
});
it('prefers new Pleroma fields', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
it('prefers new Pleroma fields', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
const result = normalizeAccount(account);
expect(result.getIn(['pleroma', 'is_active'])).toBe(true);
@ -74,38 +74,38 @@ describe('normalizeAccount()', () => {
expect(result.getIn(['pleroma', 'is_approved'])).toBe(true);
});
it('normalizes a verified Pleroma user', () => {
const account = require('soapbox/__fixtures__/mk.json');
it('normalizes a verified Pleroma user', async () => {
const account = await import('soapbox/__fixtures__/mk.json');
const result = normalizeAccount(account);
expect(result.verified).toBe(true);
});
it('normalizes an unverified Pleroma user', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
it('normalizes an unverified Pleroma user', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
const result = normalizeAccount(account);
expect(result.verified).toBe(false);
});
it('normalizes a verified Truth Social user', () => {
const account = require('soapbox/__fixtures__/realDonaldTrump.json');
it('normalizes a verified Truth Social user', async () => {
const account = await import('soapbox/__fixtures__/realDonaldTrump.json');
const result = normalizeAccount(account);
expect(result.verified).toBe(true);
});
it('normalizes Fedibird location', () => {
const account = require('soapbox/__fixtures__/fedibird-account.json');
it('normalizes Fedibird location', async () => {
const account = await import('soapbox/__fixtures__/fedibird-account.json');
const result = normalizeAccount(account);
expect(result.location).toBe('Texas, USA');
});
it('normalizes Truth Social location', () => {
const account = require('soapbox/__fixtures__/truthsocial-account.json');
it('normalizes Truth Social location', async () => {
const account = await import('soapbox/__fixtures__/truthsocial-account.json');
const result = normalizeAccount(account);
expect(result.location).toBe('Texas');
});
it('normalizes Truth Social website', () => {
const account = require('soapbox/__fixtures__/truthsocial-account.json');
it('normalizes Truth Social website', async () => {
const account = await import('soapbox/__fixtures__/truthsocial-account.json');
const result = normalizeAccount(account);
expect(result.website).toBe('https://soapbox.pub');
});
@ -128,27 +128,27 @@ describe('normalizeAccount()', () => {
expect(result.display_name).toBe('alex');
});
it('emojifies display name as `display_name_html`', () => {
const account = require('soapbox/__fixtures__/account-with-emojis.json');
it('emojifies display name as `display_name_html`', async () => {
const account = await import('soapbox/__fixtures__/account-with-emojis.json');
const result = normalizeAccount(account);
expect(result.display_name_html).toContain('emojione');
});
it('emojifies note as `note_emojified`', () => {
const account = require('soapbox/__fixtures__/account-with-emojis.json');
it('emojifies note as `note_emojified`', async () => {
const account = await import('soapbox/__fixtures__/account-with-emojis.json');
const result = normalizeAccount(account);
expect(result.note_emojified).toContain('emojione');
});
it('unescapes HTML note as `note_plain`', () => {
const account = require('soapbox/__fixtures__/account-with-emojis.json');
it('unescapes HTML note as `note_plain`', async () => {
const account = await import('soapbox/__fixtures__/account-with-emojis.json');
const result = normalizeAccount(account);
const expected = 'I create Fediverse software that empowers people online. :soapbox:\n\nI\'m vegan btw\n\nNote: If you have a question for me, please tag me publicly. This gives the opportunity for others to chime in, and bystanders to learn.';
expect(result.note_plain).toBe(expected);
});
it('emojifies custom profile field', () => {
const account = require('soapbox/__fixtures__/account-with-emojis.json');
it('emojifies custom profile field', async () => {
const account = await import('soapbox/__fixtures__/account-with-emojis.json');
const result = normalizeAccount(account);
const field = result.fields.get(1);
@ -157,8 +157,8 @@ describe('normalizeAccount()', () => {
expect(field?.value_plain).toBe('https://soapbox.pub :soapbox:');
});
it('adds default avatar and banner to GoToSocial account', () => {
const account = require('soapbox/__fixtures__/gotosocial-account.json');
it('adds default avatar and banner to GoToSocial account', async () => {
const account = await import('soapbox/__fixtures__/gotosocial-account.json');
const result = normalizeAccount(account);
expect(result.avatar).toEqual(AVATAR_MISSING);
@ -167,15 +167,15 @@ describe('normalizeAccount()', () => {
expect(result.header_static).toEqual(HEADER_MISSING);
});
it('adds fqn to Mastodon account', () => {
const account = require('soapbox/__fixtures__/mastodon-account.json');
it('adds fqn to Mastodon account', async () => {
const account = await import('soapbox/__fixtures__/mastodon-account.json');
const result = normalizeAccount(account);
expect(result.fqn).toEqual('benis911@mastodon.social');
});
it('normalizes Pleroma staff', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
it('normalizes Pleroma staff', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
const result = normalizeAccount(account);
expect(result.admin).toBe(true);
@ -183,15 +183,15 @@ describe('normalizeAccount()', () => {
expect(result.moderator).toBe(false);
});
it('normalizes Pleroma favicon', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
it('normalizes Pleroma favicon', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
const result = normalizeAccount(account);
expect(result.favicon).toEqual('https://gleasonator.com/favicon.png');
});
it('adds account domain', () => {
const account = require('soapbox/__fixtures__/pleroma-account.json');
it('adds account domain', async () => {
const account = await import('soapbox/__fixtures__/pleroma-account.json');
const result = normalizeAccount(account);
expect(result.domain).toEqual('gleasonator.com');

Wyświetl plik

@ -72,8 +72,8 @@ describe('normalizeInstance()', () => {
expect(result.toJS()).toEqual(expected);
});
it('normalizes Pleroma instance with Mastodon configuration format', () => {
const instance = require('soapbox/__fixtures__/pleroma-instance.json');
it('normalizes Pleroma instance with Mastodon configuration format', async () => {
const instance = await import('soapbox/__fixtures__/pleroma-instance.json');
const expected = {
configuration: {
@ -94,8 +94,8 @@ describe('normalizeInstance()', () => {
expect(result.toJS()).toMatchObject(expected);
});
it('normalizes Mastodon instance with retained configuration', () => {
const instance = require('soapbox/__fixtures__/mastodon-instance.json');
it('normalizes Mastodon instance with retained configuration', async () => {
const instance = await import('soapbox/__fixtures__/mastodon-instance.json');
const expected = {
configuration: {
@ -124,8 +124,8 @@ describe('normalizeInstance()', () => {
expect(result.toJS()).toMatchObject(expected);
});
it('normalizes Mastodon 3.0.0 instance with default configuration', () => {
const instance = require('soapbox/__fixtures__/mastodon-3.0.0-instance.json');
it('normalizes Mastodon 3.0.0 instance with default configuration', async () => {
const instance = await import('soapbox/__fixtures__/mastodon-3.0.0-instance.json');
const expected = {
configuration: {
@ -146,8 +146,8 @@ describe('normalizeInstance()', () => {
expect(result.toJS()).toMatchObject(expected);
});
it('normalizes Fedibird instance', () => {
const instance = require('soapbox/__fixtures__/fedibird-instance.json');
it('normalizes Fedibird instance', async () => {
const instance = await import('soapbox/__fixtures__/fedibird-instance.json');
const result = normalizeInstance(instance);
// Sets description_limit
@ -157,8 +157,8 @@ describe('normalizeInstance()', () => {
expect(result.fedibird_capabilities).toEqual(fromJS(instance.fedibird_capabilities));
});
it('normalizes Mitra instance', () => {
const instance = require('soapbox/__fixtures__/mitra-instance.json');
it('normalizes Mitra instance', async () => {
const instance = await import('soapbox/__fixtures__/mitra-instance.json');
const result = normalizeInstance(instance);
// Adds configuration and description_limit
@ -166,8 +166,8 @@ describe('normalizeInstance()', () => {
expect(result.get('description_limit')).toBe(1500);
});
it('normalizes GoToSocial instance', () => {
const instance = require('soapbox/__fixtures__/gotosocial-instance.json');
it('normalizes GoToSocial instance', async () => {
const instance = await import('soapbox/__fixtures__/gotosocial-instance.json');
const result = normalizeInstance(instance);
// Normalizes max_toot_chars
@ -179,8 +179,8 @@ describe('normalizeInstance()', () => {
expect(result.get('description_limit')).toBe(1500);
});
it('normalizes Friendica instance', () => {
const instance = require('soapbox/__fixtures__/friendica-instance.json');
it('normalizes Friendica instance', async () => {
const instance = await import('soapbox/__fixtures__/friendica-instance.json');
const result = normalizeInstance(instance);
// Normalizes max_toot_chars
@ -192,24 +192,23 @@ describe('normalizeInstance()', () => {
expect(result.get('description_limit')).toBe(1500);
});
it('normalizes a Mastodon RC version', () => {
const instance = require('soapbox/__fixtures__/mastodon-instance-rc.json');
it('normalizes a Mastodon RC version', async () => {
const instance = await import('soapbox/__fixtures__/mastodon-instance-rc.json');
const result = normalizeInstance(instance);
expect(result.version).toEqual('3.5.0-rc1');
});
it('normalizes Pixelfed instance', () => {
const instance = require('soapbox/__fixtures__/pixelfed-instance.json');
it('normalizes Pixelfed instance', async () => {
const instance = await import('soapbox/__fixtures__/pixelfed-instance.json');
const result = normalizeInstance(instance);
expect(result.title).toBe('pixelfed');
});
it('renames Akkoma to Pleroma', () => {
const instance = require('soapbox/__fixtures__/akkoma-instance.json');
it('renames Akkoma to Pleroma', async () => {
const instance = await import('soapbox/__fixtures__/akkoma-instance.json');
const result = normalizeInstance(instance);
expect(result.version).toEqual('2.7.2 (compatible; Pleroma 2.4.50+akkoma)');
});
});

Wyświetl plik

@ -28,8 +28,9 @@ describe('normalizeSoapboxConfig()', () => {
expect(result.toJS()).toMatchObject(expected);
});
it('normalizes promoPanel', () => {
const result = normalizeSoapboxConfig(require('soapbox/__fixtures__/spinster-soapbox.json'));
it('normalizes promoPanel', async () => {
const soapboxConfig = await import('soapbox/__fixtures__/spinster-soapbox.json');
const result = normalizeSoapboxConfig(soapboxConfig);
expect(ImmutableRecord.isRecord(result.promoPanel)).toBe(true);
expect(ImmutableRecord.isRecord(result.promoPanel.items.get(0))).toBe(true);
expect(result.promoPanel.items.get(2)?.icon).toBe('question-circle');

Wyświetl plik

@ -18,8 +18,8 @@ describe('normalizeStatus()', () => {
expect(result.visibility).toBe('public');
});
it('fixes the order of mentions', () => {
const status = require('soapbox/__fixtures__/status-unordered-mentions.json');
it('fixes the order of mentions', async () => {
const status = await import('soapbox/__fixtures__/status-unordered-mentions.json');
const expected = ['NEETzsche', 'alex', 'Lumeinshin', 'sneeden'];
@ -31,8 +31,8 @@ describe('normalizeStatus()', () => {
expect(result).toEqual(expected);
});
it('adds mention to self in self-reply on Mastodon', () => {
const status = require('soapbox/__fixtures__/mastodon-reply-to-self.json');
it('adds mention to self in self-reply on Mastodon', async () => {
const status = await import('soapbox/__fixtures__/mastodon-reply-to-self.json');
const expected = {
id: '106801667066418367',
@ -64,8 +64,8 @@ describe('normalizeStatus()', () => {
expect(result.toJS()).toEqual(expected);
});
it('normalizes Mitra attachments', () => {
const status = require('soapbox/__fixtures__/mitra-status-with-attachments.json');
it('normalizes Mitra attachments', async () => {
const status = await import('soapbox/__fixtures__/mitra-status-with-attachments.json');
const expected = [{
id: '017eeb0e-e5df-30a4-77a7-a929145cb836',
@ -98,8 +98,8 @@ describe('normalizeStatus()', () => {
expect(result.media_attachments.toJS()).toMatchObject(expected);
});
it('leaves Pleroma attachments alone', () => {
const status = require('soapbox/__fixtures__/pleroma-status-with-attachments.json');
it('leaves Pleroma attachments alone', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-with-attachments.json');
const result = normalizeStatus(status).media_attachments;
expect(result.size).toBe(4);
@ -108,16 +108,16 @@ describe('normalizeStatus()', () => {
expect(ImmutableRecord.isRecord(result.get(3))).toBe(true);
});
it('normalizes Pleroma quote post', () => {
const status = require('soapbox/__fixtures__/pleroma-quote-post.json');
it('normalizes Pleroma quote post', async () => {
const status = await import('soapbox/__fixtures__/pleroma-quote-post.json');
const result = normalizeStatus(status);
expect(result.quote).toEqual(fromJS(status.pleroma.quote));
expect(result.pleroma.get('quote')).toBe(undefined);
});
it('normalizes GoToSocial status', () => {
const status = require('soapbox/__fixtures__/gotosocial-status.json');
it('normalizes GoToSocial status', async () => {
const status = await import('soapbox/__fixtures__/gotosocial-status.json');
const result = normalizeStatus(status);
// Adds missing fields
@ -132,8 +132,8 @@ describe('normalizeStatus()', () => {
expect(result).toMatchObject(missing);
});
it('normalizes Friendica status', () => {
const status = require('soapbox/__fixtures__/friendica-status.json');
it('normalizes Friendica status', async () => {
const status = await import('soapbox/__fixtures__/friendica-status.json');
const result = normalizeStatus(status);
// Adds missing fields
@ -168,8 +168,8 @@ describe('normalizeStatus()', () => {
expect(poll).toMatchObject(expected);
});
it('normalizes a Pleroma logged-out poll', () => {
const status = require('soapbox/__fixtures__/pleroma-status-with-poll.json');
it('normalizes a Pleroma logged-out poll', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-with-poll.json');
const result = normalizeStatus(status);
const poll = result.poll as Poll;
@ -178,8 +178,8 @@ describe('normalizeStatus()', () => {
expect(poll.own_votes).toBe(null);
});
it('normalizes poll with emojis', () => {
const status = require('soapbox/__fixtures__/pleroma-status-with-poll-with-emojis.json');
it('normalizes poll with emojis', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-with-poll-with-emojis.json');
const result = normalizeStatus(status);
const poll = result.poll as Poll;
@ -190,8 +190,8 @@ describe('normalizeStatus()', () => {
expect(poll.emojis[1].shortcode).toEqual('soapbox');
});
it('normalizes a card', () => {
const status = require('soapbox/__fixtures__/status-with-card.json');
it('normalizes a card', async () => {
const status = await import('soapbox/__fixtures__/status-with-card.json');
const result = normalizeStatus(status);
const card = result.card as Card;

Wyświetl plik

@ -1,5 +1,6 @@
import { List as ImmutableList, Record as ImmutableRecord, Set as ImmutableSet } from 'immutable';
import announcements from 'soapbox/__fixtures__/announcements.json';
import {
ANNOUNCEMENTS_FETCH_SUCCESS,
ANNOUNCEMENTS_UPDATE,
@ -7,7 +8,6 @@ import {
import reducer from './announcements';
const announcements = require('soapbox/__fixtures__/announcements.json');
describe('accounts reducer', () => {
it('should return the initial state', () => {

Wyświetl plik

@ -317,10 +317,12 @@ describe('auth reducer', () => {
});
describe('MASTODON_PRELOAD_IMPORT', () => {
it('imports the user and token', () => {
it('imports the user and token', async () => {
const data = await import('soapbox/__fixtures__/mastodon_initial_state.json');
const action = {
type: MASTODON_PRELOAD_IMPORT,
data: require('soapbox/__fixtures__/mastodon_initial_state.json'),
data,
};
const expected = {

Wyświetl plik

@ -39,11 +39,13 @@ describe('compose reducer', () => {
});
describe('COMPOSE_SET_STATUS', () => {
it('strips Pleroma integer attachments', () => {
it('strips Pleroma integer attachments', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
const action = {
type: actions.COMPOSE_SET_STATUS,
id: 'compose-modal',
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
status: normalizeStatus(fromJS(status)),
v: { software: 'Pleroma' },
withRedraft: true,
};
@ -52,35 +54,41 @@ describe('compose reducer', () => {
expect(result.get('compose-modal')!.media_attachments.isEmpty()).toBe(true);
});
it('leaves non-Pleroma integer attachments alone', () => {
it('leaves non-Pleroma integer attachments alone', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
const action = {
type: actions.COMPOSE_SET_STATUS,
id: 'compose-modal',
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
status: normalizeStatus(fromJS(status)),
};
const result = reducer(undefined, action as any);
expect(result.get('compose-modal')!.media_attachments.getIn([0, 'id'])).toEqual('508107650');
});
it('sets the id when editing a post', () => {
it('sets the id when editing a post', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
const action = {
id: 'compose-modal',
withRedraft: false,
type: actions.COMPOSE_SET_STATUS,
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
status: normalizeStatus(fromJS(status)),
};
const result = reducer(undefined, action as any);
expect(result.get('compose-modal')!.id).toEqual('AHU2RrX0wdcwzCYjFQ');
});
it('does not set the id when redrafting a post', () => {
it('does not set the id when redrafting a post', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-deleted.json');
const action = {
id: 'compose-modal',
withRedraft: true,
type: actions.COMPOSE_SET_STATUS,
status: normalizeStatus(fromJS(require('soapbox/__fixtures__/pleroma-status-deleted.json'))),
status: normalizeStatus(fromJS(status)),
};
const result = reducer(undefined, action as any);

Wyświetl plik

@ -32,10 +32,12 @@ describe('instance reducer', () => {
});
describe('rememberInstance.fulfilled', () => {
it('normalizes Pleroma instance with Mastodon configuration format', () => {
it('normalizes Pleroma instance with Mastodon configuration format', async () => {
const payload = await import('soapbox/__fixtures__/pleroma-instance.json');
const action = {
type: rememberInstance.fulfilled.type,
payload: require('soapbox/__fixtures__/pleroma-instance.json'),
payload,
};
const result = reducer(undefined, action);
@ -58,10 +60,12 @@ describe('instance reducer', () => {
expect(result).toMatchObject(expected);
});
it('normalizes Mastodon instance with retained configuration', () => {
it('normalizes Mastodon instance with retained configuration', async () => {
const payload = await import('soapbox/__fixtures__/mastodon-instance.json');
const action = {
type: rememberInstance.fulfilled.type,
payload: require('soapbox/__fixtures__/mastodon-instance.json'),
payload,
};
const result = reducer(undefined, action);
@ -92,10 +96,12 @@ describe('instance reducer', () => {
expect(result).toMatchObject(expected);
});
it('normalizes Mastodon 3.0.0 instance with default configuration', () => {
it('normalizes Mastodon 3.0.0 instance with default configuration', async () => {
const payload = await import('soapbox/__fixtures__/mastodon-3.0.0-instance.json');
const action = {
type: rememberInstance.fulfilled.type,
payload: require('soapbox/__fixtures__/mastodon-3.0.0-instance.json'),
payload,
};
const result = reducer(undefined, action);
@ -119,8 +125,8 @@ describe('instance reducer', () => {
});
});
describe('ADMIN_CONFIG_UPDATE_REQUEST', () => {
const { configs } = require('soapbox/__fixtures__/pleroma-admin-config.json');
describe('ADMIN_CONFIG_UPDATE_REQUEST', async () => {
const { configs } = await import('soapbox/__fixtures__/pleroma-admin-config.json');
it('imports the configs', () => {
const action = {

Wyświetl plik

@ -20,16 +20,16 @@ describe('statuses reducer', () => {
});
describe('STATUS_IMPORT', () => {
it('parses the status as a Record', () => {
const status = require('soapbox/__fixtures__/pleroma-quote-post.json');
it('parses the status as a Record', async () => {
const status = await import('soapbox/__fixtures__/pleroma-quote-post.json');
const action = { type: STATUS_IMPORT, status };
const result = reducer(undefined, action).get('AFmFMSpITT9xcOJKcK');
expect(ImmutableRecord.isRecord(result)).toBe(true);
});
it('fixes the order of mentions', () => {
const status = require('soapbox/__fixtures__/status-unordered-mentions.json');
it('fixes the order of mentions', async () => {
const status = await import('soapbox/__fixtures__/status-unordered-mentions.json');
const action = { type: STATUS_IMPORT, status };
const expected = ['NEETzsche', 'alex', 'Lumeinshin', 'sneeden'];
@ -42,9 +42,9 @@ describe('statuses reducer', () => {
expect(result).toEqual(expected);
});
it('preserves the quote', () => {
const quotePost = require('soapbox/__fixtures__/pleroma-quote-post.json');
const quotedQuotePost = require('soapbox/__fixtures__/pleroma-quote-of-quote-post.json');
it('preserves the quote', async () => {
const quotePost = await import('soapbox/__fixtures__/pleroma-quote-post.json');
const quotedQuotePost = await import('soapbox/__fixtures__/pleroma-quote-of-quote-post.json');
let state = undefined;
state = reducer(state, { type: STATUS_IMPORT, status: quotePost });
@ -53,8 +53,8 @@ describe('statuses reducer', () => {
expect(state.getIn(['AFmFMSpITT9xcOJKcK', 'quote'])).toEqual('AFmFLcd6XYVdjWCrOS');
});
it('normalizes Mitra attachments', () => {
const status = require('soapbox/__fixtures__/mitra-status-with-attachments.json');
it('normalizes Mitra attachments', async () => {
const status = await import('soapbox/__fixtures__/mitra-status-with-attachments.json');
const state = reducer(undefined, { type: STATUS_IMPORT, status });
@ -87,8 +87,8 @@ describe('statuses reducer', () => {
expect(state.get('017eeb0e-e5e7-98fe-6b2b-ad02349251fb')?.media_attachments.toJS()).toMatchObject(expected);
});
it('fixes Pleroma attachments', () => {
const status = require('soapbox/__fixtures__/pleroma-status-with-attachments.json');
it('fixes Pleroma attachments', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-with-attachments.json');
const action = { type: STATUS_IMPORT, status };
const state = reducer(undefined, action);
const result = state.get('AGNkA21auFR5lnEAHw')?.media_attachments;
@ -98,24 +98,24 @@ describe('statuses reducer', () => {
expect(result?.getIn([1, 'pleroma', 'mime_type'])).toBe('application/x-nes-rom');
});
it('hides CWs', () => {
const status = require('soapbox/__fixtures__/status-cw.json');
it('hides CWs', async () => {
const status = await import('soapbox/__fixtures__/status-cw.json');
const action = { type: STATUS_IMPORT, status };
const hidden = reducer(undefined, action).getIn(['107831528995252317', 'hidden']);
expect(hidden).toBe(true);
});
it('expands CWs when expandSpoilers is enabled', () => {
const status = require('soapbox/__fixtures__/status-cw.json');
it('expands CWs when expandSpoilers is enabled', async () => {
const status = await import('soapbox/__fixtures__/status-cw.json');
const action = { type: STATUS_IMPORT, status, expandSpoilers: true };
const hidden = reducer(undefined, action).getIn(['107831528995252317', 'hidden']);
expect(hidden).toBe(false);
});
it('parses custom emojis', () => {
const status = require('soapbox/__fixtures__/status-custom-emoji.json');
it('parses custom emojis', async () => {
const status = await import('soapbox/__fixtures__/status-custom-emoji.json');
const action = { type: STATUS_IMPORT, status };
const expected = 'Hello <img draggable="false" class="emojione" alt=":ablobcathyper:" title=":ablobcathyper:" src="https://gleasonator.com/emoji/blobcat/ablobcathyper.png"> <img draggable="false" class="emojione" alt=":ageblobcat:" title=":ageblobcat:" src="https://gleasonator.com/emoji/blobcat/ageblobcat.png"> <img draggable="false" class="emojione" alt="😂" title=":joy:" src="/packs/emoji/1f602.svg"> world <img draggable="false" class="emojione" alt="😋" title=":yum:" src="/packs/emoji/1f60b.svg"> test <img draggable="false" class="emojione" alt=":blobcatphoto:" title=":blobcatphoto:" src="https://gleasonator.com/emoji/blobcat/blobcatphoto.png">';
@ -124,8 +124,8 @@ describe('statuses reducer', () => {
expect(result).toBe(expected);
});
it('builds search_index', () => {
const status = require('soapbox/__fixtures__/status-with-poll.json');
it('builds search_index', async () => {
const status = await import('soapbox/__fixtures__/status-with-poll.json');
const action = { type: STATUS_IMPORT, status };
const expected = `What is tolerance?
@ -138,8 +138,8 @@ Promoting free speech, even for people and ideas you dislike`;
expect(result).toEqual(expected);
});
it('builds search_index with mentions', () => {
const status = require('soapbox/__fixtures__/pleroma-status-reply-with-mentions.json');
it('builds search_index with mentions', async () => {
const status = await import('soapbox/__fixtures__/pleroma-status-reply-with-mentions.json');
const action = { type: STATUS_IMPORT, status };
const expected = `DMs are definitely only federated to the servers of the recipients tho. So if I DM a kfcc user, the kfcc admins can see it, but no other instance admins can.

Wyświetl plik

@ -1,7 +1,7 @@
import { groupSchema } from './group';
test('groupSchema with a TruthSocial group', () => {
const data = require('soapbox/__fixtures__/group-truthsocial.json');
test('groupSchema with a TruthSocial group', async () => {
const data = await import('soapbox/__fixtures__/group-truthsocial.json');
const group = groupSchema.parse(data);
expect(group.display_name_html).toEqual('PATRIOT PATRIOTS');
});

Wyświetl plik

@ -22,8 +22,8 @@ describe('normalizePoll()', () => {
expect(result).toMatchObject(expected);
});
it('normalizes a Pleroma logged-out poll', () => {
const { poll } = require('soapbox/__fixtures__/pleroma-status-with-poll.json');
it('normalizes a Pleroma logged-out poll', async () => {
const { poll } = await import('soapbox/__fixtures__/pleroma-status-with-poll.json');
const result = pollSchema.parse(poll);
// Adds logged-in fields
@ -31,8 +31,8 @@ describe('normalizePoll()', () => {
expect(result.own_votes).toBe(null);
});
it('normalizes poll with emojis', () => {
const { poll } = require('soapbox/__fixtures__/pleroma-status-with-poll-with-emojis.json');
it('normalizes poll with emojis', async () => {
const { poll } = await import('soapbox/__fixtures__/pleroma-status-with-poll-with-emojis.json');
const result = pollSchema.parse(poll);
// Emojifies poll options

Wyświetl plik

@ -7,8 +7,8 @@ import {
} from './status';
describe('hasIntegerMediaIds()', () => {
it('returns true for a Pleroma deleted status', () => {
const status = buildStatus(require('soapbox/__fixtures__/pleroma-status-deleted.json'));
it('returns true for a Pleroma deleted status', async () => {
const status = buildStatus(await import('soapbox/__fixtures__/pleroma-status-deleted.json') as any);
expect(hasIntegerMediaIds(status)).toBe(true);
});
});