gitlab-org--gitlab-foss/spec/javascripts/repo/components/repo_tabs_spec.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-07-25 12:13:55 -04:00
import Vue from 'vue';
import RepoStore from '~/repo/stores/repo_store';
import repoTabs from '~/repo/components/repo_tabs.vue';
2017-07-25 12:13:55 -04:00
2017-08-05 13:51:19 -04:00
describe('RepoTabs', () => {
2017-07-26 06:24:31 -04:00
const openedFiles = [{
id: 0,
active: true,
}, {
id: 1,
}];
2017-07-26 06:27:09 -04:00
2017-07-25 12:13:55 -04:00
function createComponent() {
2017-07-26 06:24:31 -04:00
const RepoTabs = Vue.extend(repoTabs);
2017-07-25 12:13:55 -04:00
return new RepoTabs().$mount();
}
it('renders a list of tabs', () => {
2017-07-26 06:24:31 -04:00
RepoStore.openedFiles = openedFiles;
const vm = createComponent();
const tabs = [...vm.$el.querySelectorAll(':scope > li')];
expect(vm.$el.id).toEqual('tabs');
2017-08-05 12:24:16 -04:00
expect(tabs.length).toEqual(3);
2017-07-26 06:24:31 -04:00
expect(tabs[0].classList.contains('active')).toBeTruthy();
expect(tabs[1].classList.contains('active')).toBeFalsy();
2017-08-05 12:24:16 -04:00
expect(tabs[2].classList.contains('tabs-divider')).toBeTruthy();
2017-07-25 12:13:55 -04:00
});
2017-08-07 08:20:51 -04:00
describe('methods', () => {
2017-08-15 14:16:42 -04:00
describe('tabClosed', () => {
2017-08-07 07:55:02 -04:00
it('calls removeFromOpenedFiles with file obj', () => {
const file = {};
spyOn(RepoStore, 'removeFromOpenedFiles');
2017-08-15 14:16:42 -04:00
repoTabs.methods.tabClosed(file);
2017-08-07 07:55:02 -04:00
expect(RepoStore.removeFromOpenedFiles).toHaveBeenCalledWith(file);
});
});
});
2017-07-25 12:13:55 -04:00
});