From 4c6589637d520daaae73a9e75396631419f47f60 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 4 Jul 2020 20:48:31 -0500 Subject: [PATCH] Tests: relationships reducers --- app/soapbox/__fixtures__/lain.json | 57 +++++++++++++++++++ .../reducers/__tests__/relationships-test.js | 32 ++++++++++- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 app/soapbox/__fixtures__/lain.json diff --git a/app/soapbox/__fixtures__/lain.json b/app/soapbox/__fixtures__/lain.json new file mode 100644 index 000000000..ab27af48e --- /dev/null +++ b/app/soapbox/__fixtures__/lain.json @@ -0,0 +1,57 @@ +{ + "acct": "lain@lain.com", + "avatar": "https://lain.com/media/0b7eb9eee68845f94dd1c7bd10d9bae90a2420cf6704de5485179c441eb0e6e0.jpg", + "avatar_static": "https://lain.com/media/0b7eb9eee68845f94dd1c7bd10d9bae90a2420cf6704de5485179c441eb0e6e0.jpg", + "bot": false, + "created_at": "2020-01-10T17:30:10.000Z", + "display_name": "Avalokiteshvara", + "emojis": [], + "fields": [], + "followers_count": 807, + "following_count": 223, + "header": "https://lain.com/media/fb0768dfa331ad730de32189d2e89b99fe51eebe1782a16cf076d7693394e4f9.png", + "header_static": "https://lain.com/media/fb0768dfa331ad730de32189d2e89b99fe51eebe1782a16cf076d7693394e4f9.png", + "id": "9v5bqYwY2jfmvPNhTM", + "locked": false, + "note": "No more hiding", + "pleroma": { + "background_image": null, + "confirmation_pending": true, + "deactivated": false, + "hide_favorites": true, + "hide_followers": false, + "hide_followers_count": false, + "hide_follows": false, + "hide_follows_count": false, + "is_admin": false, + "is_moderator": false, + "relationship": { + "blocked_by": false, + "blocking": false, + "domain_blocking": false, + "endorsed": false, + "followed_by": true, + "following": true, + "id": "9v5bqYwY2jfmvPNhTM", + "muting": false, + "muting_notifications": false, + "requested": false, + "showing_reblogs": true, + "subscribing": false + }, + "skip_thread_containment": false, + "tags": [] + }, + "source": { + "fields": [], + "note": "No more hiding", + "pleroma": { + "actor_type": "Person", + "discoverable": false + }, + "sensitive": false + }, + "statuses_count": 21107, + "url": "https://lain.com/users/lain", + "username": "lain" +} diff --git a/app/soapbox/reducers/__tests__/relationships-test.js b/app/soapbox/reducers/__tests__/relationships-test.js index 3d74e5077..657a94c44 100644 --- a/app/soapbox/reducers/__tests__/relationships-test.js +++ b/app/soapbox/reducers/__tests__/relationships-test.js @@ -1,8 +1,38 @@ import reducer from '../relationships'; -import { Map as ImmutableMap } from 'immutable'; +import { + ACCOUNT_IMPORT, +} from '../../actions/importer'; +import lain from 'soapbox/__fixtures__/lain.json'; +import { Map as ImmutableMap, fromJS } from 'immutable'; describe('relationships reducer', () => { it('should return the initial state', () => { expect(reducer(undefined, {})).toEqual(ImmutableMap()); }); + + describe('ACCOUNT_IMPORT', () => { + it('should import the relationship', () => { + const action = { + type: ACCOUNT_IMPORT, + account: lain, + }; + const state = ImmutableMap(); + expect(reducer(state, action)).toEqual(fromJS({ + '9v5bqYwY2jfmvPNhTM': { + blocked_by: false, + blocking: false, + domain_blocking: false, + endorsed: false, + followed_by: true, + following: true, + id: '9v5bqYwY2jfmvPNhTM', + muting: false, + muting_notifications: false, + requested: false, + showing_reblogs: true, + subscribing: false, + }, + })); + }); + }); });