Skip to content

Commit

Permalink
more checklist tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhchen committed Nov 8, 2016
1 parent 990ea39 commit df54986
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion test/unit/formats/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('List', function() {
`);
});

it('add checklist', function() {
it('checklist', function() {
let editor = this.initialize(Editor, `
<p>0123</p>
<p>5678</p>
Expand Down Expand Up @@ -83,6 +83,22 @@ describe('List', function() {
`);
});

it('replace checklist with bullet', function() {
let editor = this.initialize(Editor, `
<ul data-checked="true">
<li>0123</li>
</ul>
`);
editor.formatText(4, 1, { list: 'bullet' });
expect(editor.getDelta()).toEqual(new Delta()
.insert('0123')
.insert('\n', { list: 'bullet' })
);
expect(this.container).toEqualHTML(`
<ul><li>0123</li></ul>
`);
});

it('replace with attributes', function() {
let editor = this.initialize(Editor, '<ol><li class="ql-align-center">0123</li></ol>');
editor.formatText(4, 1, { list: 'bullet' });
Expand Down Expand Up @@ -161,6 +177,30 @@ describe('List', function() {
);
});

it('merge checklist', function() {
let editor = this.initialize(Editor, `
<ul data-checked="true"><li>0123</li></ul>
<p>5678</p>
<ul data-checked="true"><li>0123</li></ul>
`);
editor.formatText(9, 1, { list: 'checked' });
expect(editor.getDelta()).toEqual(new Delta()
.insert('0123')
.insert('\n', { list: 'checked' })
.insert('5678')
.insert('\n', { list: 'checked' })
.insert('0123')
.insert('\n', { list: 'checked' })
);
expect(this.container).toEqualHTML(`
<ul data-checked="true">
<li>0123</li>
<li>5678</li>
<li>0123</li>
</ul>`
);
});

it('replace split', function() {
let editor = this.initialize(Editor, `
<ol>
Expand All @@ -185,6 +225,30 @@ describe('List', function() {
);
});

it('split checklist', function() {
let editor = this.initialize(Editor, `
<ul>
<li>0123</li>
<li>5678</li>
<li>0123</li>
</ul>`
);
editor.formatText(9, 1, { list: 'unchecked' });
expect(editor.getDelta()).toEqual(new Delta()
.insert('0123')
.insert('\n', { list: 'bullet' })
.insert('5678')
.insert('\n', { list: 'unchecked' })
.insert('0123')
.insert('\n', { list: 'bullet' })
);
expect(this.container).toEqualHTML(`
<ul><li>0123</li></ul>
<ul data-checked="false"><li>5678</li></ul>
<ul><li>0123</li></ul>`
);
});

it('empty line interop', function() {
let editor = this.initialize(Editor, '<ol><li><br></li></ol>');
editor.insertText(0, 'Test');
Expand Down

0 comments on commit df54986

Please sign in to comment.