Jérémie Pardou d875eefed0
Migrate to functionnal components (#232)
* Refactor Home component

* Refactor Welcome

* Refactor small components

* Refactor Nav component

* refactor Settings

* Refactor Chat

* Refactor New message notifications

* Fix tests

* Remove tooltip

* Remove react-simple-dropdown

* Change to last redux

* Switch to redux hooks

* Add github action
2023-12-30 17:53:50 +01:00

34 lines
928 B
JavaScript

import { describe, it, expect, vi } from 'vitest';
import reducer, { createUser, changeUsername} from './user';
vi.mock('@/i18n', () => {
return {
getTranslations: vi.fn().mockReturnValue({ path: 'test' }),
};
});
describe('User reducer', () => {
it('should return the initial state', () => {
expect(reducer(undefined, {})).toEqual({ id: '', privateKey: {}, publicKey: {}, username: '' });
});
it('should handle CREATE_USER', () => {
const payload = { publicKey: { n: 'alicekey' }, username: 'alice' };
expect(reducer({},createUser(payload) )).toEqual({
id: 'alicekey',
publicKey: { n: 'alicekey' },
username: 'alice',
});
});
it('should handle SEND_ENCRYPTED_MESSAGE_CHANGE_USERNAME', () => {
const payload = { newUsername: 'alice' };
expect(reducer({ username: 'polux' }, changeUsername(payload))).toEqual({
username: 'alice',
});
});
});