import { oneLineTrim } from 'common-tags'; import Editor from '@toast-ui/editor'; import { assertWYSIWYGHTML, createEditor } from './helper/utils'; let container: HTMLElement, editor: Editor; beforeEach(() => { const editorInfo = createEditor(); container = editorInfo.container; editor = editorInfo.editor; }); afterEach(() => { editor.destroy(); document.body.removeChild(container); }); describe('addColumnToLeft command', () => { it('should add column to left and extend col-spanning cell', () => { editor.setSelection(102, 102); // select [2, 1] cell(mergedCell2-2 text) editor.exec('addColumnToLeft'); const expected = oneLineTrim`

mergedHead1

mergedHead2

mergedCell1-1

cell1-2

mergedCell1-3

mergedCell2-1


mergedCell2-2

cell2-3


cell3-1

cell4-1


cell4

cell4-3

cell5-1


cell5-2

cell5-3

`; assertWYSIWYGHTML(editor, expected); }); it('should add column to left', () => { editor.setSelection(85, 85); // select [2, 0] cell(mergedCell2-1 text) editor.exec('addColumnToLeft'); const expected = oneLineTrim`


mergedHead1

mergedHead2


mergedCell1-1

cell1-2

mergedCell1-3


mergedCell2-1

mergedCell2-2

cell2-3


cell3-1


cell4-1

cell4

cell4-3


cell5-1

cell5-2

cell5-3

`; assertWYSIWYGHTML(editor, expected); }); it('should add column to left as many as the col-spanning count', () => { editor.setSelection(38, 38); // select [1, 0] cell(mergedCell1-1 text) editor.exec('addColumnToLeft'); const expected = oneLineTrim`



mergedHead1

mergedHead2



mergedCell1-1

cell1-2

mergedCell1-3



mergedCell2-1

mergedCell2-2

cell2-3



cell3-1



cell4-1

cell4

cell4-3



cell5-1

cell5-2

cell5-3

`; assertWYSIWYGHTML(editor, expected); }); }); describe('addColumnToRight command', () => { it('should add column to right and extend col-spanning cell', () => { editor.setSelection(85, 85); // select [2, 0] cell(mergedCell2-1 text) editor.exec('addColumnToRight'); const expected = oneLineTrim`

mergedHead1

mergedHead2

mergedCell1-1

cell1-2

mergedCell1-3

mergedCell2-1


mergedCell2-2

cell2-3


cell3-1

cell4-1


cell4

cell4-3

cell5-1


cell5-2

cell5-3

`; assertWYSIWYGHTML(editor, expected); }); it('should add column to right', () => { editor.setSelection(102, 102); // select [2, 1] cell(mergedCell2-2 text) editor.exec('addColumnToRight'); const expected = oneLineTrim`

mergedHead1


mergedHead2

mergedCell1-1


cell1-2

mergedCell1-3

mergedCell2-1

mergedCell2-2


cell2-3


cell3-1

cell4-1

cell4


cell4-3

cell5-1

cell5-2


cell5-3

`; assertWYSIWYGHTML(editor, expected); }); it('should add column to right as many as the col-spanning count', () => { editor.setSelection(38, 38); // select [1, 0] cell(mergedCell1-1 text) editor.exec('addColumnToRight'); const expected = oneLineTrim`

mergedHead1



mergedHead2

mergedCell1-1



cell1-2

mergedCell1-3

mergedCell2-1

mergedCell2-2



cell2-3



cell3-1

cell4-1

cell4



cell4-3

cell5-1

cell5-2



cell5-3

`; assertWYSIWYGHTML(editor, expected); }); });