From a00a1bbc3048b27add5ca47398179d092f6bcd33 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 24 Mar 2021 15:17:05 -0500 Subject: [PATCH] Test VERIFY_CREDENTIALS_SUCCESS interactions with `me` --- app/soapbox/reducers/__tests__/auth-test.js | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/soapbox/reducers/__tests__/auth-test.js b/app/soapbox/reducers/__tests__/auth-test.js index b07716431..42bae3bf0 100644 --- a/app/soapbox/reducers/__tests__/auth-test.js +++ b/app/soapbox/reducers/__tests__/auth-test.js @@ -95,6 +95,30 @@ describe('auth reducer', () => { const result = reducer(state, action); expect(result.get('tokens')).toEqual(expected); }); + + it('sets `me` to the account if unset', () => { + const action = { + type: VERIFY_CREDENTIALS_SUCCESS, + token: 'ABCDEFG', + account: { id: '1234' }, + }; + + const result = reducer(undefined, action); + expect(result.get('me')).toEqual('1234'); + }); + + it('leaves `me` alone if already set', () => { + const action = { + type: VERIFY_CREDENTIALS_SUCCESS, + token: 'ABCDEFG', + account: { id: '1234' }, + }; + + const state = fromJS({ me: '5678' }); + + const result = reducer(state, action); + expect(result.get('me')).toEqual('5678'); + }); }); describe('VERIFY_CREDENTIALS_FAIL', () => {