diff --git a/app/soapbox/actions/__tests__/preload-test.js b/app/soapbox/actions/__tests__/preload.test.ts similarity index 100% rename from app/soapbox/actions/__tests__/preload-test.js rename to app/soapbox/actions/__tests__/preload.test.ts diff --git a/app/soapbox/actions/__tests__/statuses-test.js b/app/soapbox/actions/__tests__/statuses.test.ts similarity index 100% rename from app/soapbox/actions/__tests__/statuses-test.js rename to app/soapbox/actions/__tests__/statuses.test.ts diff --git a/app/soapbox/features/auth_login/components/__tests__/password_reset_confirm-test.js b/app/soapbox/features/auth_login/components/__tests__/password_reset_confirm.test.tsx similarity index 100% rename from app/soapbox/features/auth_login/components/__tests__/password_reset_confirm-test.js rename to app/soapbox/features/auth_login/components/__tests__/password_reset_confirm.test.tsx diff --git a/app/soapbox/features/emoji/__tests__/emoji-test.js b/app/soapbox/features/emoji/__tests__/emoji.test.ts similarity index 100% rename from app/soapbox/features/emoji/__tests__/emoji-test.js rename to app/soapbox/features/emoji/__tests__/emoji.test.ts diff --git a/app/soapbox/features/emoji/__tests__/emoji_index-test.js b/app/soapbox/features/emoji/__tests__/emoji_index.test.ts similarity index 100% rename from app/soapbox/features/emoji/__tests__/emoji_index-test.js rename to app/soapbox/features/emoji/__tests__/emoji_index.test.ts diff --git a/app/soapbox/normalizers/__tests__/account-test.js b/app/soapbox/normalizers/__tests__/account.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/account-test.js rename to app/soapbox/normalizers/__tests__/account.test.ts diff --git a/app/soapbox/normalizers/__tests__/attachment-test.js b/app/soapbox/normalizers/__tests__/attachment.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/attachment-test.js rename to app/soapbox/normalizers/__tests__/attachment.test.ts diff --git a/app/soapbox/normalizers/__tests__/card-test.js b/app/soapbox/normalizers/__tests__/card.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/card-test.js rename to app/soapbox/normalizers/__tests__/card.test.ts diff --git a/app/soapbox/normalizers/__tests__/mention-test.js b/app/soapbox/normalizers/__tests__/mention.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/mention-test.js rename to app/soapbox/normalizers/__tests__/mention.test.ts diff --git a/app/soapbox/normalizers/__tests__/notification-test.js b/app/soapbox/normalizers/__tests__/notification.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/notification-test.js rename to app/soapbox/normalizers/__tests__/notification.test.ts diff --git a/app/soapbox/normalizers/__tests__/poll-test.js b/app/soapbox/normalizers/__tests__/poll.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/poll-test.js rename to app/soapbox/normalizers/__tests__/poll.test.ts diff --git a/app/soapbox/normalizers/__tests__/status-test.js b/app/soapbox/normalizers/__tests__/status.test.ts similarity index 100% rename from app/soapbox/normalizers/__tests__/status-test.js rename to app/soapbox/normalizers/__tests__/status.test.ts diff --git a/app/soapbox/normalizers/poll.ts b/app/soapbox/normalizers/poll.ts index d2b1bf492..7b98d1354 100644 --- a/app/soapbox/normalizers/poll.ts +++ b/app/soapbox/normalizers/poll.ts @@ -47,8 +47,18 @@ const normalizeEmojis = (entity: ImmutableMap) => { }); }; -const normalizePollOption = (option: ImmutableMap, emojis: ImmutableList> = ImmutableList()) => { +const normalizePollOption = (option: ImmutableMap | string, emojis: ImmutableList> = ImmutableList()) => { const emojiMap = makeEmojiMap(emojis); + + if (typeof option === 'string') { + const titleEmojified = emojify(escapeTextContentForBrowser(option), emojiMap); + + return PollOptionRecord({ + title: option, + title_emojified: titleEmojified, + }); + } + const titleEmojified = emojify(escapeTextContentForBrowser(option.get('title')), emojiMap); return PollOptionRecord( diff --git a/app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.js b/app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.ts similarity index 100% rename from app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.js rename to app/soapbox/normalizers/soapbox/__tests__/soapbox_config-test.ts diff --git a/app/soapbox/reducers/__tests__/accounts-test.js b/app/soapbox/reducers/__tests__/accounts.test.ts similarity index 93% rename from app/soapbox/reducers/__tests__/accounts-test.js rename to app/soapbox/reducers/__tests__/accounts.test.ts index 4b7915d32..647bb676a 100644 --- a/app/soapbox/reducers/__tests__/accounts-test.js +++ b/app/soapbox/reducers/__tests__/accounts.test.ts @@ -6,7 +6,7 @@ import reducer from '../accounts'; describe('accounts reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(ImmutableMap()); + expect(reducer(undefined, {} as any)).toEqual(ImmutableMap()); }); describe('ACCOUNT_IMPORT', () => { diff --git a/app/soapbox/reducers/__tests__/accounts_counters-test.js b/app/soapbox/reducers/__tests__/accounts_counters.test.ts similarity index 95% rename from app/soapbox/reducers/__tests__/accounts_counters-test.js rename to app/soapbox/reducers/__tests__/accounts_counters.test.ts index ca1a279e0..114f28b54 100644 --- a/app/soapbox/reducers/__tests__/accounts_counters-test.js +++ b/app/soapbox/reducers/__tests__/accounts_counters.test.ts @@ -9,7 +9,7 @@ import reducer from '../accounts_counters'; describe('accounts_counters reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(ImmutableMap()); + expect(reducer(undefined, {} as any)).toEqual(ImmutableMap()); }); // it('should handle ACCOUNT_FOLLOW_SUCCESS', () => { diff --git a/app/soapbox/reducers/__tests__/admin-test.js b/app/soapbox/reducers/__tests__/admin.test.ts similarity index 84% rename from app/soapbox/reducers/__tests__/admin-test.js rename to app/soapbox/reducers/__tests__/admin.test.ts index 43018c880..a83e11022 100644 --- a/app/soapbox/reducers/__tests__/admin-test.js +++ b/app/soapbox/reducers/__tests__/admin.test.ts @@ -4,7 +4,7 @@ import reducer from '../admin'; describe('admin reducer', () => { it('should return the initial state', () => { - const result = reducer(undefined, {}); + const result = reducer(undefined, {} as any); expect(ImmutableRecord.isRecord(result)).toBe(true); expect(result.needsReboot).toBe(false); }); diff --git a/app/soapbox/reducers/__tests__/alerts-test.js b/app/soapbox/reducers/__tests__/alerts.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/alerts-test.js rename to app/soapbox/reducers/__tests__/alerts.test.ts diff --git a/app/soapbox/reducers/__tests__/auth-test.js b/app/soapbox/reducers/__tests__/auth.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/auth-test.js rename to app/soapbox/reducers/__tests__/auth.test.ts diff --git a/app/soapbox/reducers/__tests__/conversations-test.js b/app/soapbox/reducers/__tests__/conversations.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/conversations-test.js rename to app/soapbox/reducers/__tests__/conversations.test.ts diff --git a/app/soapbox/reducers/__tests__/custom_emojis-test.js b/app/soapbox/reducers/__tests__/custom_emojis.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/custom_emojis-test.js rename to app/soapbox/reducers/__tests__/custom_emojis.test.ts diff --git a/app/soapbox/reducers/__tests__/filters-test.js b/app/soapbox/reducers/__tests__/filters.test.ts similarity index 72% rename from app/soapbox/reducers/__tests__/filters-test.js rename to app/soapbox/reducers/__tests__/filters.test.ts index 90bfc1323..5faa0f948 100644 --- a/app/soapbox/reducers/__tests__/filters-test.js +++ b/app/soapbox/reducers/__tests__/filters.test.ts @@ -4,6 +4,6 @@ import reducer from '../filters'; describe('filters reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(ImmutableList()); + expect(reducer(undefined, {} as any)).toEqual(ImmutableList()); }); }); diff --git a/app/soapbox/reducers/__tests__/group_editor-test.js b/app/soapbox/reducers/__tests__/group_editor.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/group_editor-test.js rename to app/soapbox/reducers/__tests__/group_editor.test.ts diff --git a/app/soapbox/reducers/__tests__/group_lists-test.js b/app/soapbox/reducers/__tests__/group_lists.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/group_lists-test.js rename to app/soapbox/reducers/__tests__/group_lists.test.ts diff --git a/app/soapbox/reducers/__tests__/group_relationships-test.js b/app/soapbox/reducers/__tests__/group_relationships.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/group_relationships-test.js rename to app/soapbox/reducers/__tests__/group_relationships.test.ts diff --git a/app/soapbox/reducers/__tests__/groups-test.js b/app/soapbox/reducers/__tests__/groups.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/groups-test.js rename to app/soapbox/reducers/__tests__/groups.test.ts diff --git a/app/soapbox/reducers/__tests__/index-test.js b/app/soapbox/reducers/__tests__/index.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/index-test.js rename to app/soapbox/reducers/__tests__/index.test.ts diff --git a/app/soapbox/reducers/__tests__/instance-test.js b/app/soapbox/reducers/__tests__/instance.test.ts similarity index 97% rename from app/soapbox/reducers/__tests__/instance-test.js rename to app/soapbox/reducers/__tests__/instance.test.ts index 33a5fab55..8357d6851 100644 --- a/app/soapbox/reducers/__tests__/instance-test.js +++ b/app/soapbox/reducers/__tests__/instance.test.ts @@ -7,7 +7,7 @@ import reducer from '../instance'; describe('instance reducer', () => { it('should return the initial state', () => { - const result = reducer(undefined, {}); + const result = reducer(undefined, {} as any); const expected = { description_limit: 1500, @@ -128,7 +128,7 @@ describe('instance reducer', () => { }; // The normalizer has `registrations: closed` by default - const state = reducer(undefined, {}); + const state = reducer(undefined, {} as any); expect(state.registrations).toBe(false); // After importing the configs, registration will be open diff --git a/app/soapbox/reducers/__tests__/lists-test.js b/app/soapbox/reducers/__tests__/lists.test.ts similarity index 72% rename from app/soapbox/reducers/__tests__/lists-test.js rename to app/soapbox/reducers/__tests__/lists.test.ts index 56afd7a5c..43881a218 100644 --- a/app/soapbox/reducers/__tests__/lists-test.js +++ b/app/soapbox/reducers/__tests__/lists.test.ts @@ -4,6 +4,6 @@ import reducer from '../lists'; describe('lists reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(ImmutableMap()); + expect(reducer(undefined, {} as any)).toEqual(ImmutableMap()); }); }); diff --git a/app/soapbox/reducers/__tests__/me-test.js b/app/soapbox/reducers/__tests__/me.test.ts similarity index 67% rename from app/soapbox/reducers/__tests__/me-test.js rename to app/soapbox/reducers/__tests__/me.test.ts index 2c434dca4..28504ba54 100644 --- a/app/soapbox/reducers/__tests__/me-test.js +++ b/app/soapbox/reducers/__tests__/me.test.ts @@ -2,6 +2,6 @@ import reducer from '../me'; describe('me reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(null); + expect(reducer(undefined, {} as any)).toEqual(null); }); }); diff --git a/app/soapbox/reducers/__tests__/meta-test.js b/app/soapbox/reducers/__tests__/meta.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/meta-test.js rename to app/soapbox/reducers/__tests__/meta.test.ts diff --git a/app/soapbox/reducers/__tests__/mutes-test.js b/app/soapbox/reducers/__tests__/mutes.test.ts similarity index 54% rename from app/soapbox/reducers/__tests__/mutes-test.js rename to app/soapbox/reducers/__tests__/mutes.test.ts index 175f2ff38..512a5260f 100644 --- a/app/soapbox/reducers/__tests__/mutes-test.js +++ b/app/soapbox/reducers/__tests__/mutes.test.ts @@ -1,4 +1,4 @@ -import { Map as ImmutableMap } from 'immutable'; +import { Record as ImmutableRecord } from 'immutable'; import { MUTES_INIT_MODAL, @@ -9,50 +9,50 @@ import reducer from '../mutes'; describe('mutes reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(ImmutableMap({ - new: ImmutableMap({ + expect(reducer(undefined, {}).toJS()).toEqual({ + new: { isSubmitting: false, - account: null, + accountId: null, notifications: true, - }), - })); + }, + }); }); it('should handle MUTES_INIT_MODAL', () => { - const state = ImmutableMap({ - new: ImmutableMap({ + const state = ImmutableRecord({ + new: ImmutableRecord({ isSubmitting: false, - account: null, + accountId: null, notifications: true, - }), - }); + })(), + })(); const action = { type: MUTES_INIT_MODAL, - account: 'account1', + account: { id: 'account1' }, }; - expect(reducer(state, action)).toEqual(ImmutableMap({ - new: ImmutableMap({ + expect(reducer(state, action).toJS()).toEqual({ + new: { isSubmitting: false, - account: 'account1', + accountId: 'account1', notifications: true, - }), - })); + }, + }); }); it('should handle MUTES_TOGGLE_HIDE_NOTIFICATIONS', () => { - const state = ImmutableMap({ - new: ImmutableMap({ + const state = ImmutableRecord({ + new: ImmutableRecord({ notifications: true, - }), - }); + })(), + })(); const action = { type: MUTES_TOGGLE_HIDE_NOTIFICATIONS, }; - expect(reducer(state, action)).toEqual(ImmutableMap({ - new: ImmutableMap({ + expect(reducer(state, action).toJS()).toEqual({ + new: { notifications: false, - }), - })); + }, + }); }); }); diff --git a/app/soapbox/reducers/__tests__/patron-test.js b/app/soapbox/reducers/__tests__/patron.test.ts similarity index 94% rename from app/soapbox/reducers/__tests__/patron-test.js rename to app/soapbox/reducers/__tests__/patron.test.ts index 01736704b..4424285cd 100644 --- a/app/soapbox/reducers/__tests__/patron-test.js +++ b/app/soapbox/reducers/__tests__/patron.test.ts @@ -5,7 +5,7 @@ import reducer from '../patron'; describe('patron reducer', () => { it('should return the initial state', () => { - const result = reducer(undefined, {}); + const result = reducer(undefined, {} as any); expect(ImmutableRecord.isRecord(result)).toBe(true); expect(result.instance.url).toBe(''); }); diff --git a/app/soapbox/reducers/__tests__/polls-test.js b/app/soapbox/reducers/__tests__/polls.test.ts similarity index 92% rename from app/soapbox/reducers/__tests__/polls-test.js rename to app/soapbox/reducers/__tests__/polls.test.ts index b19ad858c..b9ceb07f7 100644 --- a/app/soapbox/reducers/__tests__/polls-test.js +++ b/app/soapbox/reducers/__tests__/polls.test.ts @@ -6,7 +6,7 @@ import reducer from '../polls'; describe('polls reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual(ImmutableMap()); + expect(reducer(undefined, {} as any)).toEqual(ImmutableMap()); }); describe('POLLS_IMPORT', () => { diff --git a/app/soapbox/reducers/__tests__/push_notifications-test.js b/app/soapbox/reducers/__tests__/push_notifications.test.ts similarity index 93% rename from app/soapbox/reducers/__tests__/push_notifications-test.js rename to app/soapbox/reducers/__tests__/push_notifications.test.ts index a5db7131d..e7080d42a 100644 --- a/app/soapbox/reducers/__tests__/push_notifications-test.js +++ b/app/soapbox/reducers/__tests__/push_notifications.test.ts @@ -6,7 +6,7 @@ describe('push_notifications reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap({ subscription: null, - alerts: new ImmutableMap({ + alerts: ImmutableMap({ follow: true, follow_request: true, favourite: true, diff --git a/app/soapbox/reducers/__tests__/reports-test.js b/app/soapbox/reducers/__tests__/reports.test.ts similarity index 84% rename from app/soapbox/reducers/__tests__/reports-test.js rename to app/soapbox/reducers/__tests__/reports.test.ts index 975a7ec49..77148e572 100644 --- a/app/soapbox/reducers/__tests__/reports-test.js +++ b/app/soapbox/reducers/__tests__/reports.test.ts @@ -2,7 +2,7 @@ import reducer from '../reports'; describe('reports reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {}).toJS()).toEqual({ + expect(reducer(undefined, {} as any).toJS()).toEqual({ new: { isSubmitting: false, account_id: null, diff --git a/app/soapbox/reducers/__tests__/settings-test.js b/app/soapbox/reducers/__tests__/settings.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/settings-test.js rename to app/soapbox/reducers/__tests__/settings.test.ts diff --git a/app/soapbox/reducers/__tests__/sidebar-test.js b/app/soapbox/reducers/__tests__/sidebar.test.ts similarity index 63% rename from app/soapbox/reducers/__tests__/sidebar-test.js rename to app/soapbox/reducers/__tests__/sidebar.test.ts index 511325488..83212335f 100644 --- a/app/soapbox/reducers/__tests__/sidebar-test.js +++ b/app/soapbox/reducers/__tests__/sidebar.test.ts @@ -2,6 +2,6 @@ import reducer from '../sidebar'; describe('sidebar reducer', () => { it('should return the initial state', () => { - expect(reducer(undefined, {})).toEqual({ sidebarOpen: false }); + expect(reducer(undefined, {} as any)).toEqual({ sidebarOpen: false }); }); }); diff --git a/app/soapbox/reducers/__tests__/soapbox-test.js b/app/soapbox/reducers/__tests__/soapbox.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/soapbox-test.js rename to app/soapbox/reducers/__tests__/soapbox.test.ts diff --git a/app/soapbox/reducers/__tests__/statuses-test.js b/app/soapbox/reducers/__tests__/statuses.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/statuses-test.js rename to app/soapbox/reducers/__tests__/statuses.test.ts diff --git a/app/soapbox/reducers/__tests__/trends-test.js b/app/soapbox/reducers/__tests__/trends.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/trends-test.js rename to app/soapbox/reducers/__tests__/trends.test.ts diff --git a/app/soapbox/reducers/__tests__/user_lists-test.js b/app/soapbox/reducers/__tests__/user_lists.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/user_lists-test.js rename to app/soapbox/reducers/__tests__/user_lists.test.ts diff --git a/app/soapbox/reducers/__tests__/verification-test.js b/app/soapbox/reducers/__tests__/verification.test.ts similarity index 100% rename from app/soapbox/reducers/__tests__/verification-test.js rename to app/soapbox/reducers/__tests__/verification.test.ts diff --git a/app/soapbox/utils/__tests__/accounts-test.js b/app/soapbox/utils/__tests__/accounts.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/accounts-test.js rename to app/soapbox/utils/__tests__/accounts.test.ts diff --git a/app/soapbox/utils/__tests__/base64-test.js b/app/soapbox/utils/__tests__/base64.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/base64-test.js rename to app/soapbox/utils/__tests__/base64.test.ts diff --git a/app/soapbox/utils/__tests__/colors-test.js b/app/soapbox/utils/__tests__/colors.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/colors-test.js rename to app/soapbox/utils/__tests__/colors.test.ts diff --git a/app/soapbox/utils/__tests__/features-test.js b/app/soapbox/utils/__tests__/features.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/features-test.js rename to app/soapbox/utils/__tests__/features.test.ts diff --git a/app/soapbox/utils/__tests__/html-test.js b/app/soapbox/utils/__tests__/html.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/html-test.js rename to app/soapbox/utils/__tests__/html.test.ts diff --git a/app/soapbox/utils/__tests__/phone-test.js b/app/soapbox/utils/__tests__/phone.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/phone-test.js rename to app/soapbox/utils/__tests__/phone.test.ts diff --git a/app/soapbox/utils/__tests__/status-test.js b/app/soapbox/utils/__tests__/status.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/status-test.js rename to app/soapbox/utils/__tests__/status.test.ts diff --git a/app/soapbox/utils/__tests__/tailwind-test.js b/app/soapbox/utils/__tests__/tailwind.test.ts similarity index 100% rename from app/soapbox/utils/__tests__/tailwind-test.js rename to app/soapbox/utils/__tests__/tailwind.test.ts