diff --git a/app/soapbox/reducers/__tests__/accounts-test.js b/app/soapbox/reducers/__tests__/accounts-test.js index c85c998f0..324eae15f 100644 --- a/app/soapbox/reducers/__tests__/accounts-test.js +++ b/app/soapbox/reducers/__tests__/accounts-test.js @@ -1,8 +1,297 @@ import reducer from '../accounts'; import { Map as ImmutableMap } from 'immutable'; +import * as actions from 'soapbox/actions/accounts'; describe('accounts reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap()); }); + + it('should handle ACCOUNT_IMPORT', () => { + const state = ImmutableMap({ }); + const account = { + '9w1HhmenIAKBHJiUs4': { + header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + display_name_html: 'Alex Gleason', + bot: false, + display_name: 'Alex Gleason', + created_at: '2020-06-12T21:47:28.000Z', + locked: false, + emojis: [], + header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + url: 'https://gleasonator.com/users/alex', + note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + acct: 'alex@gleasonator.com', + avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + username: 'alex', + avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + fields: [ + { + name: 'Website', + value: 'https://alexgleason.me', + name_emojified: 'Website', + value_emojified: 'https://alexgleason.me', + value_plain: 'https://alexgleason.me' + }, + { + name: 'Pleroma+Soapbox', + value: 'https://soapbox.pub', + name_emojified: 'Pleroma+Soapbox', + value_emojified: 'https://soapbox.pub', + value_plain: 'https://soapbox.pub' + }, + { + name: 'Email', + value: 'alex@alexgleason.me', + name_emojified: 'Email', + value_emojified: 'alex@alexgleason.me', + value_plain: 'alex@alexgleason.me' + }, + { + name: 'Gender identity', + value: 'Soyboy', + name_emojified: 'Gender identity', + value_emojified: 'Soyboy', + value_plain: 'Soyboy' + } + ], + pleroma: { + hide_follows: false, + hide_followers_count: false, + background_image: null, + confirmation_pending: false, + is_moderator: false, + hide_follows_count: false, + hide_followers: false, + relationship: { + showing_reblogs: true, + followed_by: false, + subscribing: false, + blocked_by: false, + requested: false, + domain_blocking: false, + following: false, + endorsed: false, + blocking: false, + muting: false, + id: '9w1HhmenIAKBHJiUs4', + muting_notifications: false + }, + tags: [], + hide_favorites: true, + is_admin: false, + skip_thread_containment: false + }, + source: { + fields: [], + note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + pleroma: { + actor_type: 'Person', + discoverable: false + }, + sensitive: false + }, + id: '9w1HhmenIAKBHJiUs4', + note_emojified: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.' + } + }; + const action = { + type: actions.ACCOUNT_IMPORT, + account: account, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + }); + }); + + it('should handle ACCOUNTS_IMPORT', () => { + const state = ImmutableMap({ }); + const accounts = { + '9w1HhmenIAKBHJiUs4': { + header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + display_name_html: 'Alex Gleason', + bot: false, + display_name: 'Alex Gleason', + created_at: '2020-06-12T21:47:28.000Z', + locked: false, + emojis: [], + header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + url: 'https://gleasonator.com/users/alex', + note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + acct: 'alex@gleasonator.com', + avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + username: 'alex', + avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + fields: [ + { + name: 'Website', + value: 'https://alexgleason.me', + name_emojified: 'Website', + value_emojified: 'https://alexgleason.me', + value_plain: 'https://alexgleason.me' + }, + { + name: 'Pleroma+Soapbox', + value: 'https://soapbox.pub', + name_emojified: 'Pleroma+Soapbox', + value_emojified: 'https://soapbox.pub', + value_plain: 'https://soapbox.pub' + }, + { + name: 'Email', + value: 'alex@alexgleason.me', + name_emojified: 'Email', + value_emojified: 'alex@alexgleason.me', + value_plain: 'alex@alexgleason.me' + }, + { + name: 'Gender identity', + value: 'Soyboy', + name_emojified: 'Gender identity', + value_emojified: 'Soyboy', + value_plain: 'Soyboy' + } + ], + pleroma: { + hide_follows: false, + hide_followers_count: false, + background_image: null, + confirmation_pending: false, + is_moderator: false, + hide_follows_count: false, + hide_followers: false, + relationship: { + showing_reblogs: true, + followed_by: false, + subscribing: false, + blocked_by: false, + requested: false, + domain_blocking: false, + following: false, + endorsed: false, + blocking: false, + muting: false, + id: '9w1HhmenIAKBHJiUs4', + muting_notifications: false + }, + tags: [], + hide_favorites: true, + is_admin: false, + skip_thread_containment: false + }, + source: { + fields: [], + note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + pleroma: { + actor_type: 'Person', + discoverable: false + }, + sensitive: false + }, + id: '9w1HhmenIAKBHJiUs4', + note_emojified: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.' + }, + '9w1HhmenIAKBHJiUs4': { + header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + display_name_html: 'Alex Gleason', + bot: false, + display_name: 'Alex Gleason', + created_at: '2020-06-12T21:47:28.000Z', + locked: false, + emojis: [], + header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + url: 'https://gleasonator.com/users/alex', + note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + acct: 'alex@gleasonator.com', + avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + username: 'alex', + avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + fields: [ + { + name: 'Website', + value: 'https://alexgleason.me', + name_emojified: 'Website', + value_emojified: 'https://alexgleason.me', + value_plain: 'https://alexgleason.me' + }, + { + name: 'Pleroma+Soapbox', + value: 'https://soapbox.pub', + name_emojified: 'Pleroma+Soapbox', + value_emojified: 'https://soapbox.pub', + value_plain: 'https://soapbox.pub' + }, + { + name: 'Email', + value: 'alex@alexgleason.me', + name_emojified: 'Email', + value_emojified: 'alex@alexgleason.me', + value_plain: 'alex@alexgleason.me' + }, + { + name: 'Gender identity', + value: 'Soyboy', + name_emojified: 'Gender identity', + value_emojified: 'Soyboy', + value_plain: 'Soyboy' + } + ], + pleroma: { + hide_follows: false, + hide_followers_count: false, + background_image: null, + confirmation_pending: false, + is_moderator: false, + hide_follows_count: false, + hide_followers: false, + relationship: { + showing_reblogs: true, + followed_by: false, + subscribing: false, + blocked_by: false, + requested: false, + domain_blocking: false, + following: false, + endorsed: false, + blocking: false, + muting: false, + id: '9w1HhmenIAKBHJiUs4', + muting_notifications: false + }, + tags: [], + hide_favorites: true, + is_admin: false, + skip_thread_containment: false + }, + source: { + fields: [], + note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + pleroma: { + actor_type: 'Person', + discoverable: false + }, + sensitive: false + }, + id: '9w1HhmenIAKBHJiUs4', + note_emojified: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.' + } + }; + const action = { + type: actions.ACCOUNTS_IMPORT, + accounts: accounts, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + }); + }); + + it('should handle ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP', () => { + const state = ImmutableMap({ username: 'curtis' }); + const action = { + type: actions.ACCOUNT_FETCH_FAIL_FOR_USERNAME_LOOKUP, + username: 'curtis', + }; + expect(reducer(state, action).toJS()).toMatchObject({ + username: 'curtis', + }); + }); + }); diff --git a/app/soapbox/reducers/__tests__/alerts-test.js b/app/soapbox/reducers/__tests__/alerts-test.js index 988859d8a..98f07b106 100644 --- a/app/soapbox/reducers/__tests__/alerts-test.js +++ b/app/soapbox/reducers/__tests__/alerts-test.js @@ -1,8 +1,43 @@ import reducer from '../alerts'; -import { List as ImmutableList } from 'immutable'; +import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import * as actions from '../alerts'; describe('alerts reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableList()); }); + + it('should handle ALERT_SHOW', () => { + const state = ImmutableMap({ key: 2 }); + const action = { + type: actions.ALERT_SHOW, + title: 'alert_title', + message: 'this is an alert message', + }; + expect(reducer(state, action).toJS()).toMatchObject({ + key: 2, + }); + }); + + it('should handle ALERT_DISMISS', () => { + const state = ImmutableMap({ key: 2 }); + const action = { + type: actions.ALERT_DISMISS, + key: 2, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + key: 2, + }); + }); + + it('should handle ALERT_CLEAR', () => { + const state = ImmutableMap({ }); + const action = { + type: actions.ALERT_CLEAR, + key: 2, + }; + expect(reducer(state, action).toJS()).toMatchObject({ + }); + }); + }); diff --git a/app/soapbox/reducers/__tests__/auth-test.js b/app/soapbox/reducers/__tests__/auth-test.js index 1eeece858..e5ea31936 100644 --- a/app/soapbox/reducers/__tests__/auth-test.js +++ b/app/soapbox/reducers/__tests__/auth-test.js @@ -1,5 +1,6 @@ import reducer from '../auth'; import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import * as actions from '../auth'; describe('auth reducer', () => { it('should return the initial state', () => { @@ -9,4 +10,15 @@ describe('auth reducer', () => { tokens: ImmutableList(), })); }); + + it('should handle AUTH_APP_CREATED', () => { + const state = ImmutableMap({ }); + const action = { + type: actions.AUTH_APP_CREATED, + app: 'soapbox', + }; + expect(reducer(state, action).toJS()).toMatchObject({ + }); + }); + }); diff --git a/app/soapbox/reducers/__tests__/compose-test.js b/app/soapbox/reducers/__tests__/compose-test.js index e03024181..cedeec216 100644 --- a/app/soapbox/reducers/__tests__/compose-test.js +++ b/app/soapbox/reducers/__tests__/compose-test.js @@ -372,103 +372,103 @@ describe('compose reducer', () => { }); }); - // it('should handle COMPOSE_MENTION', () => { - // const state = ImmutableMap({}); - // const account = { - // '9w1HhmenIAKBHJiUs4': { - // header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', - // display_name_html: 'Alex Gleason', - // bot: false, - // display_name: 'Alex Gleason', - // created_at: '2020-06-12T21:47:28.000Z', - // locked: false, - // emojis: [], - // header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', - // url: 'https://gleasonator.com/users/alex', - // note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', - // acct: 'alex@gleasonator.com', - // avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', - // username: 'alex', - // avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', - // fields: [ - // { - // name: 'Website', - // value: 'https://alexgleason.me', - // name_emojified: 'Website', - // value_emojified: 'https://alexgleason.me', - // value_plain: 'https://alexgleason.me' - // }, - // { - // name: 'Pleroma+Soapbox', - // value: 'https://soapbox.pub', - // name_emojified: 'Pleroma+Soapbox', - // value_emojified: 'https://soapbox.pub', - // value_plain: 'https://soapbox.pub' - // }, - // { - // name: 'Email', - // value: 'alex@alexgleason.me', - // name_emojified: 'Email', - // value_emojified: 'alex@alexgleason.me', - // value_plain: 'alex@alexgleason.me' - // }, - // { - // name: 'Gender identity', - // value: 'Soyboy', - // name_emojified: 'Gender identity', - // value_emojified: 'Soyboy', - // value_plain: 'Soyboy' - // } - // ], - // pleroma: { - // hide_follows: false, - // hide_followers_count: false, - // background_image: null, - // confirmation_pending: false, - // is_moderator: false, - // hide_follows_count: false, - // hide_followers: false, - // relationship: { - // showing_reblogs: true, - // followed_by: false, - // subscribing: false, - // blocked_by: false, - // requested: false, - // domain_blocking: false, - // following: false, - // endorsed: false, - // blocking: false, - // muting: false, - // id: '9w1HhmenIAKBHJiUs4', - // muting_notifications: false - // }, - // tags: [], - // hide_favorites: true, - // is_admin: false, - // skip_thread_containment: false - // }, - // source: { - // fields: [], - // note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + // it('should handle COMPOSE_MENTION', () => { + // const state = ImmutableMap({}); + // const account = { + // '9w1HhmenIAKBHJiUs4': { + // header_static: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + // display_name_html: 'Alex Gleason', + // bot: false, + // display_name: 'Alex Gleason', + // created_at: '2020-06-12T21:47:28.000Z', + // locked: false, + // emojis: [], + // header: 'https://media.gleasonator.com/accounts/headers/000/000/001/original/9d0e4dbf1c9dbc8f.png', + // url: 'https://gleasonator.com/users/alex', + // note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + // acct: 'alex@gleasonator.com', + // avatar_static: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + // username: 'alex', + // avatar: 'https://media.gleasonator.com/accounts/avatars/000/000/001/original/1a630e4c4c64c948.jpg', + // fields: [ + // { + // name: 'Website', + // value: 'https://alexgleason.me', + // name_emojified: 'Website', + // value_emojified: 'https://alexgleason.me', + // value_plain: 'https://alexgleason.me' + // }, + // { + // name: 'Pleroma+Soapbox', + // value: 'https://soapbox.pub', + // name_emojified: 'Pleroma+Soapbox', + // value_emojified: 'https://soapbox.pub', + // value_plain: 'https://soapbox.pub' + // }, + // { + // name: 'Email', + // value: 'alex@alexgleason.me', + // name_emojified: 'Email', + // value_emojified: 'alex@alexgleason.me', + // value_plain: 'alex@alexgleason.me' + // }, + // { + // name: 'Gender identity', + // value: 'Soyboy', + // name_emojified: 'Gender identity', + // value_emojified: 'Soyboy', + // value_plain: 'Soyboy' + // } + // ], // pleroma: { - // actor_type: 'Person', - // discoverable: false + // hide_follows: false, + // hide_followers_count: false, + // background_image: null, + // confirmation_pending: false, + // is_moderator: false, + // hide_follows_count: false, + // hide_followers: false, + // relationship: { + // showing_reblogs: true, + // followed_by: false, + // subscribing: false, + // blocked_by: false, + // requested: false, + // domain_blocking: false, + // following: false, + // endorsed: false, + // blocking: false, + // muting: false, + // id: '9w1HhmenIAKBHJiUs4', + // muting_notifications: false + // }, + // tags: [], + // hide_favorites: true, + // is_admin: false, + // skip_thread_containment: false // }, - // sensitive: false + // source: { + // fields: [], + // note: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.', + // pleroma: { + // actor_type: 'Person', + // discoverable: false + // }, + // sensitive: false + // }, + // id: '9w1HhmenIAKBHJiUs4', + // note_emojified: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.' // }, - // id: '9w1HhmenIAKBHJiUs4', - // note_emojified: 'Fediverse developer. I come in peace. #vegan #freeculture #atheist #antiporn #gendercritical. Boosts ≠ endorsements.' - // } - // }; - // const action = { - // type: actions.COMPOSE_MENTION, - // account: account, - // }; - // expect(reducer(state, action).toJS()).toMatchObject({ - // text: '@alex@gleasonator.com', - // caretPosition: null, - // }); + // }; + // const action = { + // type: actions.COMPOSE_MENTION, + // account: account, + // }; + // expect(reducer(state, action).toJS()).toMatchObject({ + // text: '@alex@gleasonator.com', + // caretPosition: null, // }); + // }); // it('should handle COMPOSE_DIRECT', () => { // const state = ImmutableMap({}); @@ -679,10 +679,10 @@ describe('compose reducer', () => { const initialPoll = Object({ options: [ '', - '' + '', ], expires_in: 86400, - multiple: false + multiple: false, }); const action = { type: actions.COMPOSE_POLL_ADD, @@ -711,6 +711,11 @@ describe('compose reducer', () => { // expires_in: 86400, // multiple: false // }); + // const state = ImmutableMap({ poll: initialPoll }); + // const action = { + // type: actions.COMPOSE_POLL_OPTION_ADD, + // title: 'option 3', + // }; // const updatedPoll = Object({ // options: [ // 'option 1', @@ -718,48 +723,65 @@ describe('compose reducer', () => { // 'option 3', // ], // expires_in: 86400, - // multiple: false + // multiple: false, // }); - // const state = ImmutableMap({ poll: initialPoll }); - // const action = { - // type: actions.COMPOSE_POLL_OPTION_ADD, - // title: 'option 3', - // }; // expect(reducer(state, action).toJS()).toMatchObject({ // poll: updatedPoll, // }); // }); - // it('should handle COMPOSE_POLL_OPTION_CHANGE', () => { - // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); - // const action = { - // type: actions.COMPOSE_POLL_OPTION_CHANGE, - // }; - // expect(reducer(state, action).toJS()).toMatchObject({ - // default_privacy: 'unlisted', - // privacy: 'public', - // }); - // }); - // + it('should handle COMPOSE_POLL_OPTION_CHANGE', () => { + const initialPoll = Object({ + options: [ + 'option 1', + 'option 2', + ], + expires_in: 86400, + multiple: false, + }); + const state = ImmutableMap({ poll: initialPoll }); + const action = { + type: actions.COMPOSE_POLL_OPTION_CHANGE, + index: 0, + title: 'change option', + }; + const updatedPoll = Object({ + options: [ + 'change option', + 'option 2', + ], + expires_in: 86400, + multiple: false, + }); + expect(reducer(state, action).toJS()).toMatchObject({ + poll: updatedPoll, + }); + }); + // it('should handle COMPOSE_POLL_OPTION_REMOVE', () => { - // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); + // const initialPoll = Object({ + // options: [ + // 'option 1', + // 'option 2', + // ], + // expires_in: 86400, + // multiple: false, + // }); + // const state = ImmutableMap({ poll: initialPoll }); // const action = { // type: actions.COMPOSE_POLL_OPTION_REMOVE, + // index: 1, // }; + // const updatedPoll = Object({ + // options: [ + // 'option 1', + // ], + // expires_in: 86400, + // multiple: false, + // }); // expect(reducer(state, action).toJS()).toMatchObject({ - // default_privacy: 'unlisted', - // privacy: 'public', - // }); - // }); - // - // it('should handle COMPOSE_POLL_SETTINGS_CHANGE', () => { - // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); - // const action = { - // type: actions.COMPOSE_POLL_SETTINGS_CHANGE, - // }; - // expect(reducer(state, action).toJS()).toMatchObject({ - // default_privacy: 'unlisted', - // privacy: 'public', + // poll: updatedPoll, // }); // }); + });