diff options
Diffstat (limited to 'spec/frontend/ide/stores/mutations/file_spec.js')
-rw-r--r-- | spec/frontend/ide/stores/mutations/file_spec.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/spec/frontend/ide/stores/mutations/file_spec.js b/spec/frontend/ide/stores/mutations/file_spec.js index b53e40be980..d303de6e9ef 100644 --- a/spec/frontend/ide/stores/mutations/file_spec.js +++ b/spec/frontend/ide/stores/mutations/file_spec.js @@ -39,20 +39,34 @@ describe('IDE store file mutations', () => { }); describe('TOGGLE_FILE_OPEN', () => { - beforeEach(() => { + it('adds into opened files', () => { mutations.TOGGLE_FILE_OPEN(localState, localFile.path); - }); - it('adds into opened files', () => { expect(localFile.opened).toBeTruthy(); expect(localState.openFiles.length).toBe(1); }); - it('removes from opened files', () => { + describe('if already open', () => { + it('removes from opened files', () => { + mutations.TOGGLE_FILE_OPEN(localState, localFile.path); + mutations.TOGGLE_FILE_OPEN(localState, localFile.path); + + expect(localFile.opened).toBeFalsy(); + expect(localState.openFiles.length).toBe(0); + }); + }); + + it.each` + entry | loading + ${{ opened: false }} | ${true} + ${{ opened: false, tempFile: true }} | ${false} + ${{ opened: true }} | ${false} + `('for state: $entry, sets loading=$loading', ({ entry, loading }) => { + Object.assign(localFile, entry); + mutations.TOGGLE_FILE_OPEN(localState, localFile.path); - expect(localFile.opened).toBeFalsy(); - expect(localState.openFiles.length).toBe(0); + expect(localFile.loading).toBe(loading); }); }); |