From a3df58e26090a3d1b4f842e6c3d6f9a28f12d6b1 Mon Sep 17 00:00:00 2001 From: crockwave Date: Sat, 4 Jul 2020 13:13:23 -0500 Subject: [PATCH] edited reducers/compose-test.js --- .../reducers/__tests__/compose-test.js | 156 ++++++++++++++---- 1 file changed, 124 insertions(+), 32 deletions(-) diff --git a/app/soapbox/reducers/__tests__/compose-test.js b/app/soapbox/reducers/__tests__/compose-test.js index 11d663dd3..ebb95aeea 100644 --- a/app/soapbox/reducers/__tests__/compose-test.js +++ b/app/soapbox/reducers/__tests__/compose-test.js @@ -1,5 +1,5 @@ import reducer from '../compose'; -import { Map as ImmutableMap, List as ImmutableList } from 'immutable'; +import { Map as ImmutableMap } from 'immutable'; import { ME_FETCH_SUCCESS, ME_PATCH_SUCCESS } from 'soapbox/actions/me'; import { SETTING_CHANGE } from 'soapbox/actions/settings'; import * as actions from 'soapbox/actions/compose'; @@ -470,28 +470,118 @@ describe('compose reducer', () => { // }); // }); - // it('should handle COMPOSE_DIRECT', () => { - // const state = ImmutableMap({ caretPosition: 0, privacy: 'public' }); - // const action = { - // type: actions.COMPOSE_DIRECT, - // }; - // expect(reducer(state, action).toJS()).toMatchObject({ - // caretPosition: 12, - // privacy: 'direct', + // it('should handle COMPOSE_DIRECT', () => { + // 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.COMPOSE_DIRECT, + // account: account, + // }; + // expect(reducer(state, action).toJS()).toMatchObject({ + // text: '@alex@gleasonator.com', + // caretPosition: null, + // privacy: 'direct', + // }); // }); - // }); - // - // it('should handle COMPOSE_SUGGESTIONS_CLEAR', () => { - // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); - // const action = { - // type: actions.COMPOSE_SUGGESTIONS_CLEAR, - // }; - // expect(reducer(state, action).toJS()).toMatchObject({ - // default_privacy: 'unlisted', - // privacy: 'public', - // }); - // }); // + it('should handle COMPOSE_SUGGESTIONS_CLEAR', () => { + const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); + const action = { + type: actions.COMPOSE_SUGGESTIONS_CLEAR, + suggestions: [], + suggestion_token: 'aiekdns3', + }; + expect(reducer(state, action).toJS()).toMatchObject({ + suggestion_token: null, + privacy: 'public', + }); + }); + // it('should handle COMPOSE_SUGGESTIONS_READY', () => { // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); // const action = { @@ -514,17 +604,19 @@ describe('compose reducer', () => { // }); // }); // - // it('should handle COMPOSE_SUGGESTION_TAGS_UPDATE', () => { - // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); - // const action = { - // type: actions.COMPOSE_SUGGESTION_TAGS_UPDATE, - // }; - // expect(reducer(state, action).toJS()).toMatchObject({ - // default_privacy: 'unlisted', - // privacy: 'public', - // }); - // }); - // + it('should handle COMPOSE_SUGGESTION_TAGS_UPDATE', () => { + const state = ImmutableMap({ tagHistory: [ 'hashtag' ] }); + const action = { + type: actions.COMPOSE_SUGGESTION_TAGS_UPDATE, + token: 'aaadken3', + }; + expect(reducer(state, action).toJS()).toMatchObject({ + suggestion_token: 'aaadken3', + suggestions: [], + tagHistory: [ 'hashtag', ], + }); + }); + // it('should handle COMPOSE_TAG_HISTORY_UPDATE', () => { // const state = ImmutableMap({ default_privacy: 'public', privacy: 'public'}); // const action = {