Add tests for VERIFY_CREDENTIALS_SUCCESS

merge-requests/451/head
Alex Gleason 2021-03-24 15:11:18 -05:00
rodzic 886ab93c70
commit 431e41a711
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 37 dodań i 0 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ import { Map as ImmutableMap, fromJS } from 'immutable';
import {
AUTH_APP_CREATED,
AUTH_LOGGED_IN,
VERIFY_CREDENTIALS_SUCCESS,
VERIFY_CREDENTIALS_FAIL,
} from 'soapbox/actions/auth';
@ -59,6 +60,42 @@ describe('auth reducer', () => {
});
});
describe('VERIFY_CREDENTIALS_SUCCESS', () => {
it('should import the user', () => {
const action = {
type: VERIFY_CREDENTIALS_SUCCESS,
token: 'ABCDEFG',
account: { id: '1234' },
};
const expected = fromJS({
'1234': { id: '1234', access_token: 'ABCDEFG' },
});
const result = reducer(undefined, action);
expect(result.get('users')).toEqual(expected);
});
it('should set the account in the token', () => {
const action = {
type: VERIFY_CREDENTIALS_SUCCESS,
token: 'ABCDEFG',
account: { id: '1234' },
};
const state = fromJS({
tokens: { 'ABCDEFG': { token_type: 'Bearer', access_token: 'ABCDEFG' } },
});
const expected = fromJS({
'ABCDEFG': { token_type: 'Bearer', access_token: 'ABCDEFG', account: '1234' },
});
const result = reducer(state, action);
expect(result.get('tokens')).toEqual(expected);
});
});
describe('VERIFY_CREDENTIALS_FAIL', () => {
it('should delete the failed token', () => {
const state = fromJS({