BigW Consortium Gitlab

Complete repo_file_spec

parent da75cc56
...@@ -13,7 +13,7 @@ const RepoFile = { ...@@ -13,7 +13,7 @@ const RepoFile = {
loading: { loading: {
type: Object, type: Object,
required: false, required: false,
default() { return {}; }, default() { return { tree: false }; },
}, },
hasFiles: { hasFiles: {
type: Boolean, type: Boolean,
......
...@@ -21,11 +21,10 @@ describe('RepoFile', () => { ...@@ -21,11 +21,10 @@ describe('RepoFile', () => {
}).$mount(); }).$mount();
} }
it('renders if not loading tree and has files', () => { it('renders link, icon, name and last commit details', () => {
const vm = createComponent({ const vm = createComponent({
file, file,
activeFile, activeFile,
isMini: false,
}); });
const icon = vm.$el.querySelector(`.${file.icon}`); const icon = vm.$el.querySelector(`.${file.icon}`);
const name = vm.$el.querySelector('.repo-file-name'); const name = vm.$el.querySelector('.repo-file-name');
...@@ -46,9 +45,63 @@ describe('RepoFile', () => { ...@@ -46,9 +45,63 @@ describe('RepoFile', () => {
expect(commitUpdate.textContent).toBe(file.lastCommitUpdate); expect(commitUpdate.textContent).toBe(file.lastCommitUpdate);
}); });
it('does not render if loading tree or has no files', () => {}); it('does render if hasFiles is true and is loading tree', () => {
const vm = createComponent({
file,
activeFile,
loading: {
tree: true,
},
hasFiles: true,
});
expect(vm.$el.innerHTML).toBeTruthy();
});
it('does not render if loading tree', () => {
const vm = createComponent({
file,
activeFile,
loading: {
tree: true,
},
});
expect(vm.$el.innerHTML).toBeFalsy();
});
it('does not render commit message and datetime if mini', () => {
const vm = createComponent({
file,
activeFile,
isMini: true,
});
const commitMessage = vm.$el.querySelector('.commit-message');
const commitUpdate = vm.$el.querySelector('.commit-update');
expect(commitMessage).toBeFalsy();
expect(commitUpdate).toBeFalsy();
});
it('does not set active class if file is active file', () => {
const vm = createComponent({
file,
activeFile: {},
});
it('does not render commit message and datetime if mini', () => {}); expect(vm.$el.classList.contains('active')).toBeFalsy();
});
it('does not set active class if file is active file', () => {}); it('fires linkClicked when the link is clicked', () => {
const vm = createComponent({
file,
activeFile,
});
spyOn(vm, 'linkClicked');
vm.$el.querySelector('.repo-file-name').click();
expect(vm.linkClicked).toHaveBeenCalled();
});
}); });
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