pulsar/spec/atom/cursor-spec.coffee
Nathan Sobo c8c7033550 Rename Cursor.set/getPosition to set/getScreenPosition
Now that buffer positions don't always line up with screen positions, it's important that it's clear which one we're talking about.
2012-02-24 11:53:18 -07:00

46 lines
1.2 KiB
CoffeeScript

Buffer = require 'buffer'
Editor = require 'editor'
$ = require 'jquery'
_ = require 'underscore'
fs = require 'fs'
describe "Cursor", ->
[buffer, editor, cursor] = []
beforeEach ->
buffer = new Buffer(require.resolve('fixtures/sample.js'))
editor = new Editor
editor.enableKeymap()
editor.setBuffer(buffer)
cursor = editor.cursor
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(cursor).toHaveClass 'idle'
cursor.setScreenPosition([1, 2])
expect(cursor).not.toHaveClass 'idle'
window.advanceClock(200)
expect(cursor).toHaveClass 'idle'
cursor.setScreenPosition([1, 3])
advanceClock(100)
cursor.setScreenPosition([1, 4])
advanceClock(100)
expect(cursor).not.toHaveClass 'idle'
advanceClock(100)
expect(cursor).toHaveClass 'idle'
describe ".isOnEOL()", ->
it "only returns true when cursor is on the end of a line", ->
cursor.setScreenPosition([1,29])
expect(cursor.isOnEOL()).toBeFalsy()
cursor.setScreenPosition([1,30])
expect(cursor.isOnEOL()).toBeTruthy()