Files
remark42/frontend/app/store/comments/utils.test.ts
T
2020-03-22 16:11:01 -05:00

23 lines
637 B
TypeScript

import { getInitialSort } from './utils';
import { DEFAULT_SORT, LS_SORT_KEY } from '@app/common/constants';
describe('store comments utils', () => {
beforeEach(() => {
localStorage.clear();
});
describe('getInitialSort', () => {
it('should return default sorting', () => {
expect(getInitialSort()).toBe(DEFAULT_SORT);
});
it('should return value from local storage', () => {
const currentSort = '+active';
localStorage.setItem(LS_SORT_KEY, currentSort);
expect(getInitialSort()).toBe(currentSort);
expect(localStorage.getItem).toHaveBeenCalledWith(LS_SORT_KEY);
});
});
});