import Delta from 'quill-delta';
import Quill from '../../../core/quill';
describe('Table Module', function() {
describe('insert table', function() {
it('empty', function() {
const quill = this.initialize(Quill, '
', this.container, {
modules: {
table: true,
},
});
const table = quill.getModule('table');
quill.setSelection(0);
table.insertTable(2, 3);
expect(quill.root).toEqualHTML(`
`);
});
it('split', function() {
const quill = this.initialize(Quill, '0123
', this.container, {
modules: {
table: true,
},
});
const table = quill.getModule('table');
quill.setSelection(2);
table.insertTable(2, 3);
expect(quill.root).toEqualHTML(`
23
`);
});
});
describe('modify table', function() {
beforeEach(function() {
const tableHTML = `
`;
this.quill = this.initialize(Quill, tableHTML, this.container, {
modules: {
table: true,
},
});
this.table = this.quill.getModule('table');
});
it('insertRowAbove', function() {
this.quill.setSelection(0);
this.table.insertRowAbove();
expect(this.quill.root).toEqualHTML(`
`);
});
it('insertRowBelow', function() {
this.quill.setSelection(0);
this.table.insertRowBelow();
expect(this.quill.root).toEqualHTML(`
`);
});
it('insertColumnLeft', function() {
this.quill.setSelection(0);
this.table.insertColumnLeft();
expect(this.quill.root).toEqualHTML(`
`);
});
it('insertColumnRight', function() {
this.quill.setSelection(0);
this.table.insertColumnRight();
expect(this.quill.root).toEqualHTML(`
`);
});
it('deleteRow', function() {
this.quill.setSelection(0);
this.table.deleteRow();
expect(this.quill.root).toEqualHTML(`
`);
});
it('deleteColumn', function() {
this.quill.setSelection(0);
this.table.deleteColumn();
expect(this.quill.root).toEqualHTML(`
`);
});
it('insertText before', function() {
this.quill.updateContents(new Delta().insert('\n'));
expect(this.quill.root).toEqualHTML(`
`);
});
it('insertText after', function() {
this.quill.updateContents(new Delta().retain(18).insert('\n'));
expect(this.quill.root).toEqualHTML(`
`);
});
});
});