diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-21 12:07:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-21 12:07:52 +0000 |
commit | ab72cfc3b323f2a34bd4426b9a42c13cd345b284 (patch) | |
tree | 36c0a880a177e15c43e0117949a1e460d8342068 /spec/frontend | |
parent | 483a66c030b55c7dc397d72946ba3853d0d24115 (diff) | |
download | gitlab-ce-ab72cfc3b323f2a34bd4426b9a42c13cd345b284.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/ide/stores/actions/file_spec.js | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js index e9a657ffbfc..4ec8f6b7dff 100644 --- a/spec/frontend/ide/stores/actions/file_spec.js +++ b/spec/frontend/ide/stores/actions/file_spec.js @@ -581,11 +581,13 @@ describe('IDE store file actions', () => { jest.spyOn(eventHub, '$on').mockImplementation(() => {}); jest.spyOn(eventHub, '$emit').mockImplementation(() => {}); - tmpFile = file(); + tmpFile = file('tempFile'); tmpFile.content = 'testing'; store.state.changedFiles.push(tmpFile); store.state.entries[tmpFile.path] = tmpFile; + + jest.spyOn(store, 'dispatch'); }); it('resets file content', done => { @@ -610,33 +612,35 @@ describe('IDE store file actions', () => { .catch(done.fail); }); - it('closes temp file', done => { + it('closes temp file and deletes it', () => { tmpFile.tempFile = true; tmpFile.opened = true; + tmpFile.parentPath = 'parentFile'; + store.state.entries.parentFile = file('parentFile'); - store - .dispatch('discardFileChanges', tmpFile.path) - .then(() => { - expect(tmpFile.opened).toBeFalsy(); + actions.discardFileChanges(store, tmpFile.path); - done(); - }) - .catch(done.fail); + expect(store.dispatch).toHaveBeenCalledWith('closeFile', tmpFile); + expect(store.dispatch).toHaveBeenCalledWith('deleteEntry', tmpFile.path); }); - it('does not re-open a closed temp file', done => { - tmpFile.tempFile = true; + it('renames the file to its original name and closes it if it was open', () => { + Object.assign(tmpFile, { + prevPath: 'parentPath/old_name', + prevName: 'old_name', + prevParentPath: 'parentPath', + }); - expect(tmpFile.opened).toBeFalsy(); + store.state.entries.parentPath = file('parentPath'); - store - .dispatch('discardFileChanges', tmpFile.path) - .then(() => { - expect(tmpFile.opened).toBeFalsy(); + actions.discardFileChanges(store, tmpFile.path); - done(); - }) - .catch(done.fail); + expect(store.dispatch).toHaveBeenCalledWith('closeFile', tmpFile); + expect(store.dispatch).toHaveBeenCalledWith('renameEntry', { + path: 'tempFile', + name: 'old_name', + parentPath: 'parentPath', + }); }); it('pushes route for active file', done => { |