diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
commit | 43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch) | |
tree | dceebdc68925362117480a5d672bcff122fb625b /spec/frontend/diffs/store/utils_spec.js | |
parent | 20c84b99005abd1c82101dfeff264ac50d2df211 (diff) |
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'spec/frontend/diffs/store/utils_spec.js')
-rw-r--r-- | spec/frontend/diffs/store/utils_spec.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/frontend/diffs/store/utils_spec.js b/spec/frontend/diffs/store/utils_spec.js index b5c44b084d8..4760a8b7166 100644 --- a/spec/frontend/diffs/store/utils_spec.js +++ b/spec/frontend/diffs/store/utils_spec.js @@ -892,4 +892,61 @@ describe('DiffsStoreUtils', () => { expect(files[6].right).toBeNull(); }); }); + + describe('isUrlHashNoteLink', () => { + it.each` + input | bool + ${'#note_12345'} | ${true} + ${'#12345'} | ${false} + ${'note_12345'} | ${true} + ${'12345'} | ${false} + `('returns $bool for $input', ({ bool, input }) => { + expect(utils.isUrlHashNoteLink(input)).toBe(bool); + }); + }); + + describe('isUrlHashFileHeader', () => { + it.each` + input | bool + ${'#diff-content-12345'} | ${true} + ${'#12345'} | ${false} + ${'diff-content-12345'} | ${true} + ${'12345'} | ${false} + `('returns $bool for $input', ({ bool, input }) => { + expect(utils.isUrlHashFileHeader(input)).toBe(bool); + }); + }); + + describe('parseUrlHashAsFileHash', () => { + it.each` + input | currentDiffId | resultId + ${'#note_12345'} | ${'1A2B3C'} | ${'1A2B3C'} + ${'note_12345'} | ${'1A2B3C'} | ${'1A2B3C'} + ${'#note_12345'} | ${undefined} | ${null} + ${'note_12345'} | ${undefined} | ${null} + ${'#diff-content-12345'} | ${undefined} | ${'12345'} + ${'diff-content-12345'} | ${undefined} | ${'12345'} + ${'#diff-content-12345'} | ${'98765'} | ${'12345'} + ${'diff-content-12345'} | ${'98765'} | ${'12345'} + ${'#e334a2a10f036c00151a04cea7938a5d4213a818'} | ${undefined} | ${'e334a2a10f036c00151a04cea7938a5d4213a818'} + ${'e334a2a10f036c00151a04cea7938a5d4213a818'} | ${undefined} | ${'e334a2a10f036c00151a04cea7938a5d4213a818'} + ${'#Z334a2a10f036c00151a04cea7938a5d4213a818'} | ${undefined} | ${null} + ${'Z334a2a10f036c00151a04cea7938a5d4213a818'} | ${undefined} | ${null} + `('returns $resultId for $input and $currentDiffId', ({ input, currentDiffId, resultId }) => { + expect(utils.parseUrlHashAsFileHash(input, currentDiffId)).toBe(resultId); + }); + }); + + describe('markTreeEntriesLoaded', () => { + it.each` + desc | entries | loaded | outcome + ${'marks an existing entry as loaded'} | ${{ abc: {} }} | ${[{ new_path: 'abc' }]} | ${{ abc: { diffLoaded: true } }} + ${'does nothing if the new file is not found in the tree entries'} | ${{ abc: {} }} | ${[{ new_path: 'def' }]} | ${{ abc: {} }} + ${'leaves entries unmodified if they are not in the loaded files'} | ${{ abc: {}, def: { diffLoaded: true }, ghi: {} }} | ${[{ new_path: 'ghi' }]} | ${{ abc: {}, def: { diffLoaded: true }, ghi: { diffLoaded: true } }} + `('$desc', ({ entries, loaded, outcome }) => { + expect(utils.markTreeEntriesLoaded({ priorEntries: entries, loadedFiles: loaded })).toEqual( + outcome, + ); + }); + }); }); |