Skip to content

Commit

Permalink
Update the undo-manager test to only use the userOnly option for the …
Browse files Browse the repository at this point in the history
…applicable test
  • Loading branch information
thomsbg committed Jul 17, 2015
1 parent f4e3c69 commit 06a44b7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/unit/modules/undo-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('UndoManager', ->
</div>'
@quill = new Quill(@container.firstChild, {
modules: {
'undo-manager': { delay: 400, userOnly: true }
'undo-manager': { delay: 400 }
}
})
@undoManager = @quill.getModule('undo-manager')
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('UndoManager', ->
describe('undo/redo', ->
_.each(tests, (test, name) ->
it(name, ->
@quill.updateContents(test.delta, Quill.sources.USER)
@quill.updateContents(test.delta)
changed = @quill.getContents()
expect(changed).not.toEqualDelta(@original)
@undoManager.undo()
Expand All @@ -65,9 +65,9 @@ describe('UndoManager', ->

it('merge changes', ->
expect(@undoManager.stack.undo.length).toEqual(0)
@quill.updateContents(new Quill.Delta().retain(12).insert('e'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(12).insert('e'))
expect(@undoManager.stack.undo.length).toEqual(1)
@quill.updateContents(new Quill.Delta().retain(13).insert('s'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(13).insert('s'))
expect(@undoManager.stack.undo.length).toEqual(1)
@undoManager.undo()
expect(@quill.getContents()).toEqual(@original)
Expand All @@ -76,21 +76,21 @@ describe('UndoManager', ->

it('dont merge changes', (done) ->
expect(@undoManager.stack.undo.length).toEqual(0)
@quill.updateContents(new Quill.Delta().retain(12).insert('e'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(12).insert('e'))
expect(@undoManager.stack.undo.length).toEqual(1)
setTimeout( =>
@quill.updateContents(new Quill.Delta().retain(13).insert('s'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(13).insert('s'))
expect(@undoManager.stack.undo.length).toEqual(2)
done()
, @undoManager.options.delay * 1.25)
)

it('multiple undos', (done) ->
expect(@undoManager.stack.undo.length).toEqual(0)
@quill.updateContents(new Quill.Delta().retain(12).insert('e'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(12).insert('e'))
contents = @quill.getContents()
setTimeout( =>
@quill.updateContents(new Quill.Delta().retain(13).insert('s'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(13).insert('s'))
@undoManager.undo()
expect(@quill.getContents()).toEqual(contents)
@undoManager.undo()
Expand All @@ -100,7 +100,7 @@ describe('UndoManager', ->
)

it('hotkeys', ->
@quill.updateContents(new Quill.Delta().insert('A'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().insert('A'))
changed = @quill.getContents()
expect(changed).not.toEqualDelta(@original)
dom(@quill.root).trigger('keydown', Quill.Module.UndoManager.hotkeys.UNDO)
Expand All @@ -110,6 +110,7 @@ describe('UndoManager', ->
)

it('api change transform', ->
@quill.getModule('undo-manager').options.userOnly = true
@quill.updateContents(new Quill.Delta().retain(12).insert('es'), Quill.sources.USER)
@quill.updateContents(new Quill.Delta().retain(4).delete(5), Quill.sources.API)
@quill.updateContents(new Quill.Delta().retain(9).insert('!'), Quill.sources.USER)
Expand Down

0 comments on commit 06a44b7

Please sign in to comment.