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

removed tests as code is already tested in store

parent 174c2f80
<script>
import icon from '~/vue_shared/components/icon.vue';
import repoTree from './ide_repo_tree.vue';
import newDropdown from './new_dropdown/index.vue';
import icon from '~/vue_shared/components/icon.vue';
import repoTree from './ide_repo_tree.vue';
import newDropdown from './new_dropdown/index.vue';
export default {
components: {
repoTree,
icon,
newDropdown,
},
props: {
projectId: {
type: String,
required: true,
export default {
components: {
repoTree,
icon,
newDropdown,
},
branch: {
type: Object,
required: true,
props: {
projectId: {
type: String,
required: true,
},
branch: {
type: Object,
required: true,
},
},
},
};
};
</script>
<template>
......@@ -40,7 +40,7 @@ export default {
/>
</div>
</div>
<template v-if="branch.tree">
<template v-if="branch.tree.length">
<repo-tree
:tree="branch.tree"
/>
......
......@@ -29,11 +29,13 @@ export default {
<skeleton-loading-container />
</div>
</template>
<repo-file
v-for="file in tree.tree"
:key="file.key"
:file="file"
:level="0"
/>
<template v-else>
<repo-file
v-for="file in tree.tree"
:key="file.key"
:file="file"
:level="0"
/>
</template>
</div>
</template>
......@@ -7,6 +7,7 @@
},
path: {
type: String,
required: false,
default: '',
},
},
......
......@@ -32,8 +32,12 @@ describe('new dropdown component', () => {
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')[1].textContent.trim()).toBe('Upload file');
expect(vm.$el.querySelectorAll('a')[2].textContent.trim()).toBe('New directory');
expect(vm.$el.querySelectorAll('a')[1].textContent.trim()).toBe(
'Upload file',
);
expect(vm.$el.querySelectorAll('a')[2].textContent.trim()).toBe(
'New directory',
);
});
describe('createNewItem', () => {
......@@ -49,7 +53,7 @@ describe('new dropdown component', () => {
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();
Vue.nextTick(() => {
......@@ -61,12 +65,12 @@ describe('new dropdown component', () => {
});
describe('hideModal', () => {
beforeAll((done) => {
beforeAll(done => {
vm.openModal = true;
Vue.nextTick(done);
});
it('closes modal after toggling', (done) => {
it('closes modal after toggling', done => {
vm.hideModal();
Vue.nextTick()
......@@ -77,123 +81,4 @@ describe('new dropdown component', () => {
.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', () => {
});
describe('updateViewer', () => {
it('updates viewer state', (done) => {
store.dispatch('updateViewer', 'diff')
it('updates viewer state', done => {
store
.dispatch('updateViewer', 'diff')
.then(() => {
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