diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 09:07:49 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-10 09:07:49 +0000 |
commit | 0ba3a054d2190094ffda1ebe3aa53ffc5b92247d (patch) | |
tree | 8462503456eb030bb1042c6af73edc8f8af49fc6 /spec/frontend/ide/stores | |
parent | b24ae1cbc66e5b0f622393bcf2c59711750161ea (diff) | |
download | gitlab-ce-0ba3a054d2190094ffda1ebe3aa53ffc5b92247d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/stores')
-rw-r--r-- | spec/frontend/ide/stores/actions/file_spec.js | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js index 4ec8f6b7dff..8ba7b554f43 100644 --- a/spec/frontend/ide/stores/actions/file_spec.js +++ b/spec/frontend/ide/stores/actions/file_spec.js @@ -9,6 +9,7 @@ import router from '~/ide/ide_router'; import eventHub from '~/ide/eventhub'; import { file } from '../../helpers'; +const ORIGINAL_CONTENT = 'original content'; const RELATIVE_URL_ROOT = '/gitlab'; describe('IDE store file actions', () => { @@ -583,6 +584,7 @@ describe('IDE store file actions', () => { tmpFile = file('tempFile'); tmpFile.content = 'testing'; + tmpFile.raw = ORIGINAL_CONTENT; store.state.changedFiles.push(tmpFile); store.state.entries[tmpFile.path] = tmpFile; @@ -594,7 +596,7 @@ describe('IDE store file actions', () => { store .dispatch('discardFileChanges', tmpFile.path) .then(() => { - expect(tmpFile.content).not.toBe('testing'); + expect(tmpFile.content).toBe(ORIGINAL_CONTENT); done(); }) @@ -624,22 +626,30 @@ describe('IDE store file actions', () => { expect(store.dispatch).toHaveBeenCalledWith('deleteEntry', tmpFile.path); }); - 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', - }); + describe('with renamed file', () => { + beforeEach(() => { + Object.assign(tmpFile, { + prevPath: 'parentPath/old_name', + prevName: 'old_name', + prevParentPath: 'parentPath', + }); - store.state.entries.parentPath = file('parentPath'); + store.state.entries.parentPath = file('parentPath'); - actions.discardFileChanges(store, tmpFile.path); + actions.discardFileChanges(store, tmpFile.path); + }); - expect(store.dispatch).toHaveBeenCalledWith('closeFile', tmpFile); - expect(store.dispatch).toHaveBeenCalledWith('renameEntry', { - path: 'tempFile', - name: 'old_name', - parentPath: 'parentPath', + it('renames the file to its original name and closes it if it was open', () => { + expect(store.dispatch).toHaveBeenCalledWith('closeFile', tmpFile); + expect(store.dispatch).toHaveBeenCalledWith('renameEntry', { + path: 'tempFile', + name: 'old_name', + parentPath: 'parentPath', + }); + }); + + it('resets file content', () => { + expect(tmpFile.content).toBe(ORIGINAL_CONTENT); }); }); |