debian-mirror-gitlab/spec/frontend/diffs/utils/preferences_spec.js

33 lines
1,013 B
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import Cookies from 'js-cookie';
import {
DIFF_FILE_BY_FILE_COOKIE_NAME,
DIFF_VIEW_FILE_BY_FILE,
DIFF_VIEW_ALL_FILES,
} from '~/diffs/constants';
2021-03-11 19:13:27 +05:30
import { fileByFile } from '~/diffs/utils/preferences';
2021-02-22 17:27:13 +05:30
describe('diffs preferences', () => {
describe('fileByFile', () => {
2021-04-17 20:07:23 +05:30
afterEach(() => {
Cookies.remove(DIFF_FILE_BY_FILE_COOKIE_NAME);
});
2021-02-22 17:27:13 +05:30
it.each`
2021-04-17 20:07:23 +05:30
result | preference | cookie
${true} | ${false} | ${DIFF_VIEW_FILE_BY_FILE}
${false} | ${true} | ${DIFF_VIEW_ALL_FILES}
${true} | ${false} | ${DIFF_VIEW_FILE_BY_FILE}
${false} | ${true} | ${DIFF_VIEW_ALL_FILES}
${false} | ${false} | ${DIFF_VIEW_ALL_FILES}
${true} | ${true} | ${DIFF_VIEW_FILE_BY_FILE}
2021-02-22 17:27:13 +05:30
`(
2021-04-17 20:07:23 +05:30
'should return $result when { preference: $preference, cookie: $cookie }',
({ result, preference, cookie }) => {
Cookies.set(DIFF_FILE_BY_FILE_COOKIE_NAME, cookie);
2021-02-22 17:27:13 +05:30
expect(fileByFile(preference)).toBe(result);
},
);
});
});