diff options
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/notebook/cells/code_spec.js | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/spec/javascripts/notebook/cells/code_spec.js b/spec/javascripts/notebook/cells/code_spec.js index 4659b83d1b6..f3f97145ad3 100644 --- a/spec/javascripts/notebook/cells/code_spec.js +++ b/spec/javascripts/notebook/cells/code_spec.js @@ -11,14 +11,19 @@ describe('Code component', () => { json = getJSONFixture('blob/notebook/basic.json'); }); + const setupComponent = cell => { + const comp = new Component({ + propsData: { + cell, + }, + }); + comp.$mount(); + return comp; + }; + describe('without output', () => { beforeEach(done => { - vm = new Component({ - propsData: { - cell: json.cells[0], - }, - }); - vm.$mount(); + vm = setupComponent(json.cells[0]); setTimeout(() => { done(); @@ -32,12 +37,7 @@ describe('Code component', () => { describe('with output', () => { beforeEach(done => { - vm = new Component({ - propsData: { - cell: json.cells[2], - }, - }); - vm.$mount(); + vm = setupComponent(json.cells[2]); setTimeout(() => { done(); @@ -52,4 +52,23 @@ describe('Code component', () => { expect(vm.$el.querySelector('.output')).toBeDefined(); }); }); + + describe('with string for cell.source', () => { + beforeEach(done => { + const cell = json.cells[0]; + cell.source = cell.source.join(''); + + vm = setupComponent(cell); + + setTimeout(() => { + done(); + }); + }); + + it('renders the same input as when cell.source is an array', () => { + const expected = "console.log('test')"; + + expect(vm.$el.querySelector('.input').innerText).toContain(expected); + }); + }); }); |