diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/frontend/diffs/utils | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/frontend/diffs/utils')
-rw-r--r-- | spec/frontend/diffs/utils/interoperability_spec.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/frontend/diffs/utils/interoperability_spec.js b/spec/frontend/diffs/utils/interoperability_spec.js new file mode 100644 index 00000000000..2557e83cb4c --- /dev/null +++ b/spec/frontend/diffs/utils/interoperability_spec.js @@ -0,0 +1,67 @@ +import { + getInteropInlineAttributes, + getInteropNewSideAttributes, + getInteropOldSideAttributes, + ATTR_TYPE, + ATTR_LINE, + ATTR_NEW_LINE, + ATTR_OLD_LINE, +} from '~/diffs/utils/interoperability'; + +describe('~/diffs/utils/interoperability', () => { + describe('getInteropInlineAttributes', () => { + it.each([ + ['with null input', { input: null, output: null }], + [ + 'with type=old input', + { + input: { type: 'old', old_line: 3, new_line: 5 }, + output: { [ATTR_TYPE]: 'old', [ATTR_LINE]: 3, [ATTR_OLD_LINE]: 3, [ATTR_NEW_LINE]: 5 }, + }, + ], + [ + 'with type=old-nonewline input', + { + input: { type: 'old-nonewline', old_line: 3, new_line: 5 }, + output: { [ATTR_TYPE]: 'old', [ATTR_LINE]: 3, [ATTR_OLD_LINE]: 3, [ATTR_NEW_LINE]: 5 }, + }, + ], + [ + 'with type=new input', + { + input: { type: 'new', old_line: 3, new_line: 5 }, + output: { [ATTR_TYPE]: 'new', [ATTR_LINE]: 5, [ATTR_OLD_LINE]: 3, [ATTR_NEW_LINE]: 5 }, + }, + ], + [ + 'with type=bogus input', + { + input: { type: 'bogus', old_line: 3, new_line: 5 }, + output: { [ATTR_TYPE]: 'new', [ATTR_LINE]: 5, [ATTR_OLD_LINE]: 3, [ATTR_NEW_LINE]: 5 }, + }, + ], + ])('%s', (desc, { input, output }) => { + expect(getInteropInlineAttributes(input)).toEqual(output); + }); + }); + + describe('getInteropOldSideAttributes', () => { + it.each` + input | output + ${null} | ${null} + ${{ old_line: 2 }} | ${{ [ATTR_TYPE]: 'old', [ATTR_LINE]: 2, [ATTR_OLD_LINE]: 2 }} + `('with input=$input', ({ input, output }) => { + expect(getInteropOldSideAttributes(input)).toEqual(output); + }); + }); + + describe('getInteropNewSideAttributes', () => { + it.each` + input | output + ${null} | ${null} + ${{ new_line: 2 }} | ${{ [ATTR_TYPE]: 'new', [ATTR_LINE]: 2, [ATTR_NEW_LINE]: 2 }} + `('with input=$input', ({ input, output }) => { + expect(getInteropNewSideAttributes(input)).toEqual(output); + }); + }); +}); |