2017-04-11 17:50:21 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import Notebook from '~/notebook/index.vue';
|
|
|
|
|
|
|
|
const Component = Vue.extend(Notebook);
|
|
|
|
|
|
|
|
describe('Notebook component', () => {
|
|
|
|
let vm;
|
2017-04-11 20:25:10 +00:00
|
|
|
let json;
|
|
|
|
let jsonWithWorksheet;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
json = getJSONFixture('blob/notebook/basic.json');
|
|
|
|
jsonWithWorksheet = getJSONFixture('blob/notebook/worksheets.json');
|
|
|
|
});
|
2017-04-11 17:50:21 +00:00
|
|
|
|
|
|
|
describe('without JSON', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-04-11 17:50:21 +00:00
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
notebook: {},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
vm.$mount();
|
|
|
|
|
2020-05-08 09:09:39 +00:00
|
|
|
setImmediate(() => {
|
2017-04-11 17:50:21 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render', () => {
|
|
|
|
expect(vm.$el.tagName).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with JSON', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-04-11 17:50:21 +00:00
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
notebook: json,
|
|
|
|
codeCssClass: 'js-code-class',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
vm.$mount();
|
|
|
|
|
2020-05-08 09:09:39 +00:00
|
|
|
setImmediate(() => {
|
2017-04-11 17:50:21 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders cells', () => {
|
|
|
|
expect(vm.$el.querySelectorAll('.cell').length).toBe(json.cells.length);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders markdown cell', () => {
|
|
|
|
expect(vm.$el.querySelector('.markdown')).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders code cell', () => {
|
|
|
|
expect(vm.$el.querySelector('pre')).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('add code class to code blocks', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-code-class')).not.toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with worksheets', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-04-11 17:50:21 +00:00
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
notebook: jsonWithWorksheet,
|
|
|
|
codeCssClass: 'js-code-class',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
vm.$mount();
|
|
|
|
|
2020-05-08 09:09:39 +00:00
|
|
|
setImmediate(() => {
|
2017-04-11 17:50:21 +00:00
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders cells', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
expect(vm.$el.querySelectorAll('.cell').length).toBe(
|
|
|
|
jsonWithWorksheet.worksheets[0].cells.length,
|
|
|
|
);
|
2017-04-11 17:50:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders markdown cell', () => {
|
|
|
|
expect(vm.$el.querySelector('.markdown')).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders code cell', () => {
|
|
|
|
expect(vm.$el.querySelector('pre')).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('add code class to code blocks', () => {
|
|
|
|
expect(vm.$el.querySelector('.js-code-class')).not.toBeNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|