未验证 提交 59f666da 编写于 作者: P Phil Hughes

file action specs

上级 6a34d254
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', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册