Skip to content
Snippets Groups Projects
Commit 7173ab8e authored by Phil Hughes's avatar Phil Hughes
Browse files

Added JS specs

parent 70be03e7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -87,6 +87,7 @@ export default class XlsxService {
columnHeaders.push(val.v);
}
}
return columnHeaders;
}
}
import Vue from 'vue';
import table from '~/blob/xlsx/components/table.vue';
describe('XLSX table', () => {
let vm;
beforeEach((done) => {
const TableComponent = Vue.extend(table);
vm = new TableComponent({
propsData: {
sheet: {},
},
}).$mount();
Vue.nextTick(done);
});
describe('linePath', () => {
it('returns linePath with just the number when hash is empty', () => {
expect(
vm.linePath(0),
).toBe('#L1');
});
it('returns linePath with just the number when hash has a value', () => {
location.hash = 'test';
expect(
vm.linePath(0),
).toBe('#test-L1');
});
});
describe('getCurrentLineNumberFromUrl', () => {
it('gets line number', () => {
location.hash = 'L1';
vm.getCurrentLineNumberFromUrl();
expect(
vm.currentLineNumber,
).toBe(1);
});
it('gets line number when hash has sheet name', () => {
location.hash = 'test-L1';
vm.getCurrentLineNumberFromUrl();
expect(
vm.currentLineNumber,
).toBe(1);
});
});
});
import Vue from 'vue';
import tabs from '~/blob/xlsx/components/tabs.vue';
describe('XLSX tabs', () => {
let vm;
beforeEach((done) => {
const TabsComponent = Vue.extend(tabs);
vm = new TabsComponent({
propsData: {
currentSheetName: 'test 1',
sheetNames: ['test 1', 'test 2'],
},
}).$mount();
Vue.nextTick(done);
});
it('changes hash to sheet name', () => {
vm.changeSheet('test 2');
expect(
location.hash,
).toBe(`#${encodeURIComponent('test 2')}`);
});
it('selects current sheet name', () => {
expect(
vm.$el.querySelector('li:first-child'),
).toHaveClass('active');
expect(
vm.$el.querySelector('li:nth-child(2)'),
).not.toHaveClass('active');
});
});
import Vue from 'vue';
import Service from '~/blob/xlsx/service';
import component from '~/blob/xlsx/index.vue';
describe('XLSX Renderer', () => {
let vm;
beforeEach((done) => {
const RendererComponent = Vue.extend(component);
spyOn(Service.prototype, 'getData').and.callFake(() => new Promise((resolve) => {
resolve({
test: {},
'test 1': {},
});
setTimeout(done, 0);
}));
vm = new RendererComponent({
propsData: {
endpoint: '/',
},
}).$mount();
});
afterEach(() => {
location.hash = '';
});
describe('getInitialSheet', () => {
it('defaults to first sheet', () => {
expect(
vm.currentSheetName,
).toBe('test');
});
it('uses hash for currentSheetName', () => {
location.hash = 'test 1';
expect(
vm.getInitialSheet(),
).toBe('test 1');
});
it('defaults to first sheet if hash is not found in sheetNames', () => {
location.hash = 'test 2';
expect(
vm.getInitialSheet(),
).toBe('test');
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment