pulsar/spec/app/cursor-spec.coffee
Nathan Sobo 4e74f1bf2e Fix issues with selections when switching between edit sessions
SelectionViews now update their appearance immediately when constructed. We can't assume they're empty. CursorView doesn't do a blanket `off()` call to its model when it's removed anymore, which was screwing up selection updates when switching back. Only attach selections / cursors when the editor is attached, and extract everything we do into a `renderWhenAttached` method.
2012-06-11 22:01:27 -06:00

39 lines
1.0 KiB
CoffeeScript

Buffer = require 'buffer'
Editor = require 'editor'
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
describe "Cursor", ->
[buffer, editor, cursorView, cursor] = []
beforeEach ->
buffer = new Buffer(require.resolve('fixtures/sample.js'))
editor = new Editor
editor.enableKeymap()
editor.setBuffer(buffer)
editor.attachToDom()
cursor = editor.getCursor()
cursorView = editor.getCursorView()
describe "adding and removing of the idle class", ->
it "removes the idle class while moving, then adds it back when it stops", ->
advanceClock(200)
expect(cursorView).toHaveClass 'idle'
cursor.setScreenPosition([1, 2])
expect(cursorView).not.toHaveClass 'idle'
window.advanceClock(200)
expect(cursorView).toHaveClass 'idle'
cursor.setScreenPosition([1, 3])
advanceClock(100)
cursor.setScreenPosition([1, 4])
advanceClock(100)
expect(cursorView).not.toHaveClass 'idle'
advanceClock(100)
expect(cursorView).toHaveClass 'idle'