blob: 10762a1c3a21537709e3975c669c20d7a49540c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
import { mount } from '@vue/test-utils';
import fixture from 'test_fixtures/blob/notebook/basic.json';
import Code from '~/notebook/cells/code.vue';
describe('Code component', () => {
let wrapper;
let json;
const mountComponent = (cell) => mount(Code, { propsData: { cell } });
beforeEach(() => {
// Clone fixture as it could be modified by tests
json = JSON.parse(JSON.stringify(fixture));
});
afterEach(() => {
wrapper.destroy();
});
describe('without output', () => {
beforeEach(() => {
wrapper = mountComponent(json.cells[0]);
});
it('does not render output prompt', () => {
expect(wrapper.findAll('.prompt')).toHaveLength(1);
});
});
describe('with output', () => {
beforeEach(() => {
wrapper = mountComponent(json.cells[2]);
});
it('does not render output prompt', () => {
expect(wrapper.findAll('.prompt')).toHaveLength(2);
});
it('renders output cell', () => {
expect(wrapper.find('.output').exists()).toBe(true);
});
});
describe('with string for output', () => {
// NBFormat Version 4.1 allows outputs.text to be a string
beforeEach(() => {
const cell = json.cells[2];
cell.outputs[0].text = cell.outputs[0].text.join('');
wrapper = mountComponent(cell);
});
it('does not render output prompt', () => {
expect(wrapper.findAll('.prompt')).toHaveLength(2);
});
it('renders output cell', () => {
expect(wrapper.find('.output').exists()).toBe(true);
});
});
describe('with string for cell.source', () => {
beforeEach(() => {
const cell = json.cells[0];
cell.source = cell.source.join('');
wrapper = mountComponent(cell);
});
it('renders the same input as when cell.source is an array', () => {
expect(wrapper.find('.input').text()).toContain("console.log('test')");
});
});
});
|