From 2089cb124d1f8b8bde286c3cb33e8acea54e9727 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 12 Mar 2022 14:52:03 -0600 Subject: [PATCH] Test account.moved --- app/soapbox/__fixtures__/account-moved.json | 46 ++++++++++++++++ .../reducers/__tests__/accounts-test.js | 52 ++++--------------- 2 files changed, 56 insertions(+), 42 deletions(-) create mode 100644 app/soapbox/__fixtures__/account-moved.json diff --git a/app/soapbox/__fixtures__/account-moved.json b/app/soapbox/__fixtures__/account-moved.json new file mode 100644 index 000000000..dbb194916 --- /dev/null +++ b/app/soapbox/__fixtures__/account-moved.json @@ -0,0 +1,46 @@ +{ + "id": "106801667066418367", + "username": "benis911", + "acct": "benis911", + "display_name": "", + "locked": false, + "bot": false, + "discoverable": null, + "group": false, + "created_at": "2021-08-22T00:00:00.000Z", + "note": "", + "url": "https://mastodon.social/@benis911", + "avatar": "https://mastodon.social/avatars/original/missing.png", + "avatar_static": "https://mastodon.social/avatars/original/missing.png", + "header": "https://mastodon.social/headers/original/missing.png", + "header_static": "https://mastodon.social/headers/original/missing.png", + "followers_count": 0, + "following_count": 0, + "statuses_count": 5, + "last_status_at": "2022-02-23", + "moved": { + "id": "107945464165013501", + "username": "alex", + "acct": "alex@fedibird.com", + "display_name": "", + "locked": false, + "bot": false, + "discoverable": false, + "group": false, + "created_at": "2020-01-27T00:00:00.000Z", + "note": "

", + "url": "https://fedibird.com/@alex", + "avatar": "https://mastodon.social/avatars/original/missing.png", + "avatar_static": "https://mastodon.social/avatars/original/missing.png", + "header": "https://mastodon.social/headers/original/missing.png", + "header_static": "https://mastodon.social/headers/original/missing.png", + "followers_count": 1, + "following_count": 1, + "statuses_count": 5, + "last_status_at": null, + "emojis": [], + "fields": [] + }, + "emojis": [], + "fields": [] +} diff --git a/app/soapbox/reducers/__tests__/accounts-test.js b/app/soapbox/reducers/__tests__/accounts-test.js index 973ac4f1e..4b7915d32 100644 --- a/app/soapbox/reducers/__tests__/accounts-test.js +++ b/app/soapbox/reducers/__tests__/accounts-test.js @@ -1,11 +1,8 @@ -import { Map as ImmutableMap, Record } from 'immutable'; +import { Map as ImmutableMap, Record as ImmutableRecord } from 'immutable'; import { ACCOUNT_IMPORT } from 'soapbox/actions/importer'; import reducer from '../accounts'; -// import * as actions from 'soapbox/actions/importer'; -// import { take } from 'lodash'; -// import accounts from 'soapbox/__fixtures__/accounts.json'; describe('accounts reducer', () => { it('should return the initial state', () => { @@ -18,44 +15,15 @@ describe('accounts reducer', () => { const action = { type: ACCOUNT_IMPORT, account }; const result = reducer(undefined, action).get('9v5bmRalQvjOy0ECcC'); - expect(Record.isRecord(result)).toBe(true); + expect(ImmutableRecord.isRecord(result)).toBe(true); + }); + + it('minifies a moved account', () => { + const account = require('soapbox/__fixtures__/account-moved.json'); + const action = { type: ACCOUNT_IMPORT, account }; + const result = reducer(undefined, action).get('106801667066418367'); + + expect(result.moved).toBe('107945464165013501'); }); }); - - // fails to add normalized accounts to state - // it('should handle ACCOUNT_IMPORT', () => { - // const state = ImmutableMap({ }); - // const account = take(accounts, 1); - // const action = { - // type: actions.ACCOUNT_IMPORT, - // account: account, - // }; - // debugger; - // expect(reducer(state, action).toJS()).toMatchObject({ - // }); - // }); - - // fails to add normalized accounts to state - // it('should handle ACCOUNTS_IMPORT', () => { - // const state = ImmutableMap({ }); - // const accounts = take(accounts, 2); - // 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', - // }); - // }); - });