diff --git a/docs/src/demos/Nodes/Table/index.spec.js b/docs/src/demos/Nodes/Table/index.spec.js index 7f58e674..75f20351 100644 --- a/docs/src/demos/Nodes/Table/index.spec.js +++ b/docs/src/demos/Nodes/Table/index.spec.js @@ -3,5 +3,75 @@ context('/demos/Nodes/Table', () => { cy.visit('/demos/Nodes/Table') }) - // TODO: Write tests + beforeEach(() => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.clearContent() + }) + }) + + it('creates a table (1x1)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false }) + + cy.get('.ProseMirror').find('td').its('length').should('eq', 1) + cy.get('.ProseMirror').find('tr').its('length').should('eq', 1) + }) + }) + + it('creates a table (3x1)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable({ cols: 3, rows: 1, withHeaderRow: false }) + + cy.get('.ProseMirror').find('td').its('length').should('eq', 3) + cy.get('.ProseMirror').find('tr').its('length').should('eq', 1) + }) + }) + + it('creates a table (1x3)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable({ cols: 1, rows: 3, withHeaderRow: false }) + + cy.get('.ProseMirror').find('td').its('length').should('eq', 3) + cy.get('.ProseMirror').find('tr').its('length').should('eq', 3) + }) + }) + + it('creates a table with header row (1x3)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable({ cols: 1, rows: 3, withHeaderRow: true }) + + cy.get('.ProseMirror').find('th').its('length').should('eq', 1) + cy.get('.ProseMirror').find('td').its('length').should('eq', 2) + cy.get('.ProseMirror').find('tr').its('length').should('eq', 3) + }) + }) + + it('creates a table with correct defaults (3x3, th)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable() + + cy.get('.ProseMirror').find('th').its('length').should('eq', 3) + cy.get('.ProseMirror').find('td').its('length').should('eq', 6) + cy.get('.ProseMirror').find('tr').its('length').should('eq', 3) + }) + }) + + it('generates correct markup for a table (1x1)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: false }) + + const html = editor.getHTML() + expect(html).to.equal('

') + }) + }) + + it('generates correct markup for a table (1x1, th)', () => { + cy.get('.ProseMirror').then(([{ editor }]) => { + editor.commands.insertTable({ cols: 1, rows: 1, withHeaderRow: true }) + + const html = editor.getHTML() + expect(html).to.equal('

') + }) + }) + }) diff --git a/docs/src/demos/Nodes/Table/index.vue b/docs/src/demos/Nodes/Table/index.vue index 6df0fecd..1841f5a0 100644 --- a/docs/src/demos/Nodes/Table/index.vue +++ b/docs/src/demos/Nodes/Table/index.vue @@ -42,7 +42,7 @@ -