diff options
Diffstat (limited to 'spec/frontend/diffs/store/getters_spec.js')
-rw-r--r-- | spec/frontend/diffs/store/getters_spec.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/spec/frontend/diffs/store/getters_spec.js b/spec/frontend/diffs/store/getters_spec.js index 2e3a66d5b01..ed7b6699e2c 100644 --- a/spec/frontend/diffs/store/getters_spec.js +++ b/spec/frontend/diffs/store/getters_spec.js @@ -288,6 +288,19 @@ describe('Diffs Module Getters', () => { }); }); + describe('isTreePathLoaded', () => { + it.each` + desc | loaded | path | bool + ${'the file exists and has been loaded'} | ${true} | ${'path/tofile'} | ${true} + ${'the file exists and has not been loaded'} | ${false} | ${'path/tofile'} | ${false} + ${'the file does not exist'} | ${false} | ${'tofile/path'} | ${false} + `('returns $bool when $desc', ({ loaded, path, bool }) => { + localState.treeEntries['path/tofile'] = { diffLoaded: loaded }; + + expect(getters.isTreePathLoaded(localState)(path)).toBe(bool); + }); + }); + describe('allBlobs', () => { it('returns an array of blobs', () => { localState.treeEntries = { @@ -328,7 +341,11 @@ describe('Diffs Module Getters', () => { describe('currentDiffIndex', () => { it('returns index of currently selected diff in diffList', () => { - localState.diffFiles = [{ file_hash: '111' }, { file_hash: '222' }, { file_hash: '333' }]; + localState.treeEntries = [ + { type: 'blob', fileHash: '111' }, + { type: 'blob', fileHash: '222' }, + { type: 'blob', fileHash: '333' }, + ]; localState.currentDiffFileId = '222'; expect(getters.currentDiffIndex(localState)).toEqual(1); @@ -339,7 +356,11 @@ describe('Diffs Module Getters', () => { }); it('returns 0 if no diff is selected yet or diff is not found', () => { - localState.diffFiles = [{ file_hash: '111' }, { file_hash: '222' }, { file_hash: '333' }]; + localState.treeEntries = [ + { type: 'blob', fileHash: '111' }, + { type: 'blob', fileHash: '222' }, + { type: 'blob', fileHash: '333' }, + ]; localState.currentDiffFileId = ''; expect(getters.currentDiffIndex(localState)).toEqual(0); |