diff options
author | Phil Hughes <me@iamphill.com> | 2017-11-08 17:20:46 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-11-10 16:56:00 +0000 |
commit | 59f666da6057e9822dc66d48135220eef795ec3b (patch) | |
tree | a93271fd0d31599682104281763fe0eb683cd6af | |
parent | 6a34d2542310d8f56e8fd367ad3a108813db5f7e (diff) | |
download | gitlab-ce-59f666da6057e9822dc66d48135220eef795ec3b.tar.gz |
file action specs
-rw-r--r-- | spec/javascripts/repo/stores/actions/file_spec.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/javascripts/repo/stores/actions/file_spec.js b/spec/javascripts/repo/stores/actions/file_spec.js index 5e6a8461982..0149989ced5 100644 --- a/spec/javascripts/repo/stores/actions/file_spec.js +++ b/spec/javascripts/repo/stores/actions/file_spec.js @@ -1,3 +1,7 @@ +import store from '~/repo/stores'; +import service from '~/repo/services'; +import { file } from '../../helpers'; + describe('Multi-file store file actions', () => { describe('closeFile', () => { @@ -12,11 +16,51 @@ describe('Multi-file store file actions', () => { }); describe('getRawFileData', () => { + let tmpFile; + + beforeEach(() => { + spyOn(service, 'getRawFileData').and.returnValue(Promise.resolve('raw')); + + tmpFile = file(); + }); + + it('calls getRawFileData service method', (done) => { + store.dispatch('getRawFileData', tmpFile) + .then(() => { + expect(service.getRawFileData).toHaveBeenCalledWith(tmpFile); + done(); + }).catch(done.fail); + }); + + it('updates file raw data', (done) => { + store.dispatch('getRawFileData', tmpFile) + .then(() => { + expect(tmpFile.raw).toBe('raw'); + + done(); + }).catch(done.fail); + }); }); describe('changeFileContent', () => { + let tmpFile; + + beforeEach(() => { + tmpFile = file(); + }); + + it('updates file content', (done) => { + store.dispatch('changeFileContent', { + file: tmpFile, + content: 'content', + }) + .then(() => { + expect(tmpFile.content).toBe('content'); + done(); + }).catch(done.fail); + }); }); describe('createTempFile', () => { |