debian-mirror-gitlab/spec/frontend/notebook/index_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-11-11 11:23:49 +05:30
import { mount } from '@vue/test-utils';
2023-05-27 22:25:52 +05:30
import { nextTick } from 'vue';
2021-11-18 22:05:49 +05:30
import json from 'test_fixtures/blob/notebook/basic.json';
import jsonWithWorksheet from 'test_fixtures/blob/notebook/worksheets.json';
2017-08-17 22:00:37 +05:30
import Notebook from '~/notebook/index.vue';
describe('Notebook component', () => {
let vm;
2021-11-11 11:23:49 +05:30
function buildComponent(notebook) {
2023-05-27 22:25:52 +05:30
return mount(Notebook, {
2022-10-11 01:57:18 +05:30
propsData: { notebook },
2021-11-11 11:23:49 +05:30
provide: { relativeRawPath: '' },
}).vm;
}
2017-08-17 22:00:37 +05:30
describe('without JSON', () => {
2022-04-04 11:22:00 +05:30
beforeEach(() => {
2021-11-11 11:23:49 +05:30
vm = buildComponent({});
2017-08-17 22:00:37 +05:30
2022-04-04 11:22:00 +05:30
return nextTick();
2017-08-17 22:00:37 +05:30
});
it('does not render', () => {
expect(vm.$el.tagName).toBeUndefined();
});
});
describe('with JSON', () => {
2022-04-04 11:22:00 +05:30
beforeEach(() => {
2021-11-11 11:23:49 +05:30
vm = buildComponent(json);
2017-08-17 22:00:37 +05:30
2022-04-04 11:22:00 +05:30
return nextTick();
2017-08-17 22:00:37 +05:30
});
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();
});
});
describe('with worksheets', () => {
2022-04-04 11:22:00 +05:30
beforeEach(() => {
2021-11-11 11:23:49 +05:30
vm = buildComponent(jsonWithWorksheet);
2017-08-17 22:00:37 +05:30
2022-04-04 11:22:00 +05:30
return nextTick();
2017-08-17 22:00:37 +05:30
});
it('renders cells', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelectorAll('.cell').length).toBe(
jsonWithWorksheet.worksheets[0].cells.length,
);
2017-08-17 22:00:37 +05:30
});
it('renders markdown cell', () => {
expect(vm.$el.querySelector('.markdown')).not.toBeNull();
});
it('renders code cell', () => {
expect(vm.$el.querySelector('pre')).not.toBeNull();
});
});
});