forked from mycolorway/simditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: h5 tag bug in title button #332
- Loading branch information
1 parent
7648c33
commit abbb5f4
Showing
6 changed files
with
118 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(function() { | ||
describe('Simditor title button', function() { | ||
var $p, editor; | ||
editor = null; | ||
$p = null; | ||
beforeEach(function() { | ||
editor = spec.generateSimditor({ | ||
content: '<p>paragraph 1</>', | ||
toolbar: ['title'] | ||
}); | ||
editor.focus(); | ||
$p = editor.body.find('> p'); | ||
editor.selection.setRangeAtStartOf($p); | ||
return editor.trigger('selectionchanged'); | ||
}); | ||
afterEach(function() { | ||
spec.destroySimditor(); | ||
return editor = null; | ||
}); | ||
it("can convert paragraph to h1", function() { | ||
var $firstBlock, button; | ||
$firstBlock = editor.body.children().first(); | ||
expect($firstBlock.is('p')).toBe(true); | ||
expect($firstBlock.is('h1')).toBe(false); | ||
button = editor.toolbar.list.find('.toolbar-item-title').data('button'); | ||
button.menuEl.find('.menu-item-h1').click(); | ||
$firstBlock = editor.body.children().first(); | ||
expect($firstBlock.is('p')).toBe(false); | ||
expect($firstBlock.is('h1')).toBe(true); | ||
button.menuEl.find('.menu-item-normal').click(); | ||
$firstBlock = editor.body.children().first(); | ||
expect($firstBlock.is('p')).toBe(true); | ||
return expect($firstBlock.is('h1')).toBe(false); | ||
}); | ||
return it("can convert paragraph to h5", function() { | ||
var $firstBlock, button; | ||
$firstBlock = editor.body.children().first(); | ||
expect($firstBlock.is('p')).toBe(true); | ||
expect($firstBlock.is('h5')).toBe(false); | ||
button = editor.toolbar.list.find('.toolbar-item-title').data('button'); | ||
button.menuEl.find('.menu-item-h5').click(); | ||
$firstBlock = editor.body.children().first(); | ||
expect($firstBlock.is('p')).toBe(false); | ||
expect($firstBlock.is('h5')).toBe(true); | ||
button.menuEl.find('.menu-item-normal').click(); | ||
$firstBlock = editor.body.children().first(); | ||
expect($firstBlock.is('p')).toBe(true); | ||
return expect($firstBlock.is('h5')).toBe(false); | ||
}); | ||
}); | ||
|
||
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
describe 'Simditor title button', -> | ||
editor = null | ||
$p = null | ||
|
||
beforeEach -> | ||
editor = spec.generateSimditor | ||
content: ''' | ||
<p>paragraph 1</> | ||
''' | ||
toolbar: ['title'] | ||
editor.focus() | ||
|
||
$p = editor.body.find('> p') | ||
editor.selection.setRangeAtStartOf $p | ||
editor.trigger 'selectionchanged' | ||
|
||
afterEach -> | ||
spec.destroySimditor() | ||
editor = null | ||
|
||
it "can convert paragraph to h1", -> | ||
$firstBlock = editor.body.children().first() | ||
expect($firstBlock.is('p')).toBe(true) | ||
expect($firstBlock.is('h1')).toBe(false) | ||
|
||
button = editor.toolbar.list.find('.toolbar-item-title').data 'button' | ||
button.menuEl.find('.menu-item-h1').click() | ||
$firstBlock = editor.body.children().first() | ||
expect($firstBlock.is('p')).toBe(false) | ||
expect($firstBlock.is('h1')).toBe(true) | ||
|
||
button.menuEl.find('.menu-item-normal').click() | ||
$firstBlock = editor.body.children().first() | ||
expect($firstBlock.is('p')).toBe(true) | ||
expect($firstBlock.is('h1')).toBe(false) | ||
|
||
it "can convert paragraph to h5", -> | ||
$firstBlock = editor.body.children().first() | ||
expect($firstBlock.is('p')).toBe(true) | ||
expect($firstBlock.is('h5')).toBe(false) | ||
|
||
button = editor.toolbar.list.find('.toolbar-item-title').data 'button' | ||
button.menuEl.find('.menu-item-h5').click() | ||
$firstBlock = editor.body.children().first() | ||
expect($firstBlock.is('p')).toBe(false) | ||
expect($firstBlock.is('h5')).toBe(true) | ||
|
||
button.menuEl.find('.menu-item-normal').click() | ||
$firstBlock = editor.body.children().first() | ||
expect($firstBlock.is('p')).toBe(true) | ||
expect($firstBlock.is('h5')).toBe(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters