2020-02-16 11:50:38 +00:00
|
|
|
import { getters } from '../../auth';
|
|
|
|
|
|
|
|
import '../../../../routes';
|
|
|
|
|
|
|
|
jest.mock('../../../../routes', () => {});
|
|
|
|
describe('#getters', () => {
|
|
|
|
it('isLoggedIn', () => {
|
|
|
|
expect(getters.isLoggedIn({ currentUser: { id: null } })).toEqual(false);
|
|
|
|
expect(getters.isLoggedIn({ currentUser: { id: 1 } })).toEqual(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('getCurrentUserID', () => {
|
|
|
|
expect(getters.getCurrentUserID({ currentUser: { id: 1 } })).toEqual(1);
|
|
|
|
});
|
|
|
|
it('getCurrentUser', () => {
|
|
|
|
expect(
|
|
|
|
getters.getCurrentUser({ currentUser: { id: 1, name: 'Pranav' } })
|
|
|
|
).toEqual({ id: 1, name: 'Pranav' });
|
|
|
|
});
|
2020-07-04 14:33:16 +00:00
|
|
|
|
|
|
|
it('get', () => {
|
|
|
|
expect(
|
2021-10-14 19:00:48 +00:00
|
|
|
getters.getCurrentUserAvailability({
|
2021-10-07 07:51:46 +00:00
|
|
|
currentAccountId: 1,
|
|
|
|
currentUser: {
|
|
|
|
id: 1,
|
2021-10-14 19:00:48 +00:00
|
|
|
accounts: [{ id: 1, availability: 'busy' }],
|
2021-10-07 07:51:46 +00:00
|
|
|
},
|
2020-07-04 14:33:16 +00:00
|
|
|
})
|
|
|
|
).toEqual('busy');
|
|
|
|
});
|
2021-01-10 13:55:33 +00:00
|
|
|
|
|
|
|
it('getUISettings', () => {
|
|
|
|
expect(
|
|
|
|
getters.getUISettings({
|
|
|
|
currentUser: { ui_settings: { is_contact_sidebar_open: true } },
|
|
|
|
})
|
|
|
|
).toEqual({ is_contact_sidebar_open: true });
|
|
|
|
});
|
2022-02-15 05:08:24 +00:00
|
|
|
describe('#getMessageSignature', () => {
|
|
|
|
it('Return signature when signature is present', () => {
|
|
|
|
expect(
|
|
|
|
getters.getMessageSignature({
|
|
|
|
currentUser: { message_signature: 'Thanks' },
|
|
|
|
})
|
|
|
|
).toEqual('Thanks');
|
|
|
|
});
|
|
|
|
it('Return empty string when signature is not present', () => {
|
|
|
|
expect(
|
|
|
|
getters.getMessageSignature({
|
|
|
|
currentUser: {},
|
|
|
|
})
|
|
|
|
).toEqual('');
|
|
|
|
});
|
|
|
|
});
|
2020-02-16 11:50:38 +00:00
|
|
|
});
|