Commit 7a73d29e authored by Phil Hughes's avatar Phil Hughes

spec fixes

parent 389a4efc
......@@ -182,16 +182,18 @@ export const updateDirectoryData = (
state,
});
const formattedData = [
let formattedData = [
...data.trees.map(t => createEntry(t, 'tree')),
...data.submodules.map(m => createEntry(m, 'submodule')),
...data.blobs.map(b => createEntry(b, 'blob')),
];
if (!clearTree) {
formattedData.push(
state.changedFiles.filter(f => f.tempFile && f.path === `${tree.path}/${f.name}`),
);
if (!clearTree && tree) {
const tempFiles = state.changedFiles.filter(f => f.tempFile && f.path === `${tree.path}/${f.name}`);
if (tempFiles.length) {
formattedData = formattedData.concat(tempFiles);
}
}
commit(types.SET_DIRECTORY_DATA, { tree: selectedTree, data: formattedData });
......
......@@ -66,7 +66,7 @@ describe('RepoFile', () => {
spyOn(vm, 'clickFile');
vm.$el.click();
vm.$el.querySelector('td').click();
expect(vm.clickFile).toHaveBeenCalledWith(vm.file);
});
......
......@@ -55,20 +55,6 @@ describe('Multi-file store file actions', () => {
.catch(done.fail);
});
it('sets next file as active', (done) => {
const f = file('otherfile');
store.state.openFiles.push(f);
expect(f.active).toBeFalsy();
store.dispatch('closeFile', localFile)
.then(() => {
expect(f.active).toBeTruthy();
done();
}).catch(done.fail);
});
it('calls getLastCommitData', (done) => {
store.dispatch('closeFile', localFile)
.then(() => {
......
......@@ -39,7 +39,7 @@ describe('Multi-file store tree actions', () => {
last_commit_path: 'last_commit_path',
parent_tree_url: 'parent_tree_url',
path: '/',
trees: [{ name: 'tree' }],
trees: [{ name: 'tree', path: 'tree' }],
blobs: [{ name: 'blob' }],
submodules: [{ name: 'submodule' }],
}),
......@@ -68,6 +68,30 @@ describe('Multi-file store tree actions', () => {
}).catch(done.fail);
});
it('adds temp files into tree', (done) => {
const f = {
...file('tempFile'),
path: 'tree/tempFile',
tempFile: true,
};
store.state.changedFiles.push(f);
store.dispatch('getTreeData', basicCallParameters)
.then(() => store.dispatch('getTreeData', {
...basicCallParameters,
tree: store.state.trees['abcproject/master'].tree[0],
}))
.then(() => {
const tree = store.state.trees['abcproject/master'].tree[0].tree;
expect(tree.length).toBe(4);
expect(tree[3].name).toBe(f.name);
done();
}).catch(done.fail);
});
it('sets parent tree URL', (done) => {
store.dispatch('getTreeData', basicCallParameters)
.then(() => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment