Commit 813ea768 authored by Phil Hughes's avatar Phil Hughes

removed tests as code is already tested in store

parent 174c2f80
<script> <script>
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import repoTree from './ide_repo_tree.vue'; import repoTree from './ide_repo_tree.vue';
import newDropdown from './new_dropdown/index.vue'; import newDropdown from './new_dropdown/index.vue';
export default { export default {
components: { components: {
repoTree, repoTree,
icon, icon,
newDropdown, newDropdown,
},
props: {
projectId: {
type: String,
required: true,
}, },
branch: { props: {
type: Object, projectId: {
required: true, type: String,
required: true,
},
branch: {
type: Object,
required: true,
},
}, },
}, };
};
</script> </script>
<template> <template>
...@@ -40,7 +40,7 @@ export default { ...@@ -40,7 +40,7 @@ export default {
/> />
</div> </div>
</div> </div>
<template v-if="branch.tree"> <template v-if="branch.tree.length">
<repo-tree <repo-tree
:tree="branch.tree" :tree="branch.tree"
/> />
......
...@@ -29,11 +29,13 @@ export default { ...@@ -29,11 +29,13 @@ export default {
<skeleton-loading-container /> <skeleton-loading-container />
</div> </div>
</template> </template>
<repo-file <template v-else>
v-for="file in tree.tree" <repo-file
:key="file.key" v-for="file in tree.tree"
:file="file" :key="file.key"
:level="0" :file="file"
/> :level="0"
/>
</template>
</div> </div>
</template> </template>
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
}, },
path: { path: {
type: String, type: String,
required: false,
default: '', default: '',
}, },
}, },
......
...@@ -32,8 +32,12 @@ describe('new dropdown component', () => { ...@@ -32,8 +32,12 @@ describe('new dropdown component', () => {
it('renders new file, upload and new directory links', () => { it('renders new file, upload and new directory links', () => {
expect(vm.$el.querySelectorAll('a')[0].textContent.trim()).toBe('New file'); expect(vm.$el.querySelectorAll('a')[0].textContent.trim()).toBe('New file');
expect(vm.$el.querySelectorAll('a')[1].textContent.trim()).toBe('Upload file'); expect(vm.$el.querySelectorAll('a')[1].textContent.trim()).toBe(
expect(vm.$el.querySelectorAll('a')[2].textContent.trim()).toBe('New directory'); 'Upload file',
);
expect(vm.$el.querySelectorAll('a')[2].textContent.trim()).toBe(
'New directory',
);
}); });
describe('createNewItem', () => { describe('createNewItem', () => {
...@@ -49,7 +53,7 @@ describe('new dropdown component', () => { ...@@ -49,7 +53,7 @@ describe('new dropdown component', () => {
expect(vm.modalType).toBe('tree'); expect(vm.modalType).toBe('tree');
}); });
it('opens modal when link is clicked', (done) => { it('opens modal when link is clicked', done => {
vm.$el.querySelectorAll('a')[0].click(); vm.$el.querySelectorAll('a')[0].click();
Vue.nextTick(() => { Vue.nextTick(() => {
...@@ -61,12 +65,12 @@ describe('new dropdown component', () => { ...@@ -61,12 +65,12 @@ describe('new dropdown component', () => {
}); });
describe('hideModal', () => { describe('hideModal', () => {
beforeAll((done) => { beforeAll(done => {
vm.openModal = true; vm.openModal = true;
Vue.nextTick(done); Vue.nextTick(done);
}); });
it('closes modal after toggling', (done) => { it('closes modal after toggling', done => {
vm.hideModal(); vm.hideModal();
Vue.nextTick() Vue.nextTick()
...@@ -77,123 +81,4 @@ describe('new dropdown component', () => { ...@@ -77,123 +81,4 @@ describe('new dropdown component', () => {
.catch(done.fail); .catch(done.fail);
}); });
}); });
// TODO: move all this to the action spec
describe('createTempEntry', () => {
['tree', 'blob'].forEach((type) => {
if (type === 'blob') {
it('creates new file', (done) => {
vm.createTempEntry({
branchId: 'mybranch',
name: 'testing',
type,
}).then(() => {
const baseTree = vm.$store.state.trees['abcproject/mybranch'].tree;
expect(baseTree.length).toBe(1);
expect(baseTree[0].name).toBe('testing');
expect(baseTree[0].type).toBe('blob');
expect(baseTree[0].tempFile).toBeTruthy();
done();
})
.catch(done.fail);
});
it('does not create temp file when file already exists', (done) => {
const baseTree = vm.$store.state.trees['abcproject/mybranch'].tree;
baseTree.push(file('testing', '1', type));
vm.createTempEntry({
branchId: 'mybranch',
name: 'testing',
type,
})
.then(() => {
expect(baseTree.length).toBe(1);
expect(baseTree[0].name).toBe('testing');
expect(baseTree[0].type).toBe('blob');
expect(baseTree[0].tempFile).toBeFalsy();
done();
})
.catch(done.fail);
});
} else {
it('creates new tree', (done) => {
vm.createTempEntry({
branchId: 'mybranch',
name: 'testing',
type,
})
.then(() => {
const baseTree = vm.$store.state.trees['abcproject/mybranch'].tree;
expect(baseTree.length).toBe(1);
expect(baseTree[0].name).toBe('testing');
expect(baseTree[0].type).toBe('tree');
expect(baseTree[0].tempFile).toBeTruthy();
done();
})
.catch(done.fail);
});
it('creates multiple trees when entryName has slashes', (done) => {
vm.createTempEntry({
branchId: 'mybranch',
name: 'app/test',
type,
})
.then(() => {
const baseTree = vm.$store.state.trees['abcproject/mybranch'].tree;
expect(baseTree.length).toBe(1);
expect(baseTree[0].name).toBe('app');
done();
})
.catch(done.fail);
});
it('creates tree in existing tree', (done) => {
const f = file('app', '1', 'tree');
const baseTree = vm.$store.state.trees['abcproject/mybranch'].tree;
baseTree.push(f);
vm.$store.state.entries[f.path] = f;
vm.entryName = 'app/test';
vm.createTempEntry({
branchId: 'mybranch',
name: 'app/test',
type,
}).then(() => {
expect(baseTree.length).toBe(1);
// console.log(baseTree[0].tree);
expect(baseTree[0].name).toBe('app');
expect(baseTree[0].tempFile).toBeFalsy();
expect(baseTree[0].tree[0].tempFile).toBeTruthy();
expect(baseTree[0].tree[0].name).toBe('test');
done();
}).catch(done.fail);
});
it('does not create new tree when already exists', (done) => {
const baseTree = vm.$store.state.trees['abcproject/mybranch'].tree;
baseTree.push(file('app', '1', 'tree'));
vm.createTempEntry({
branchId: 'mybranch',
name: 'app',
type,
}).then(() => {
expect(baseTree.length).toBe(1);
expect(baseTree[0].name).toBe('app');
expect(baseTree[0].tempFile).toBeFalsy();
expect(baseTree[0].tree.length).toBe(0);
done();
}).catch(done.fail);
});
}
});
});
}); });
...@@ -293,8 +293,9 @@ describe('Multi-file store actions', () => { ...@@ -293,8 +293,9 @@ describe('Multi-file store actions', () => {
}); });
describe('updateViewer', () => { describe('updateViewer', () => {
it('updates viewer state', (done) => { it('updates viewer state', done => {
store.dispatch('updateViewer', 'diff') store
.dispatch('updateViewer', 'diff')
.then(() => { .then(() => {
expect(store.state.viewer).toBe('diff'); expect(store.state.viewer).toBe('diff');
}) })
......
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