Make test use word under cursor

This commit is contained in:
Corey Johnson
2013-01-21 14:38:47 -08:00
parent 46d20250d3
commit f2dcf40a2c

View File

@@ -271,37 +271,37 @@ describe 'FuzzyFinder', ->
expect(finder.list.find("li:contains(tree-view.js)")).not.toExist()
describe "fuzzy find by content under cursor", ->
editor = null
beforeEach ->
editor = rootView.getActiveEditor()
rootView.attachToDom()
spyOn(rootView.project, "getFilePaths").andCallThrough()
it "opens the fuzzy finder window when there are multiple matches", ->
cursor = rootView.getActiveEditor().getCursor()
spyOn(cursor, "getCurrentWord").andReturn("sample")
editor.setText("sample")
rootView.trigger 'fuzzy-finder:find-under-cursor'
waitsFor ->
finder.list.children('li').length > 0
runs ->
expect(rootView.find('.fuzzy-finder')).toExist()
expect(finder).toBeVisible()
expect(rootView.find('.fuzzy-finder input:focus')).toExist()
it "opens a file directly when there is a single match", ->
cursor = rootView.getActiveEditor().getCursor()
spyOn(cursor, "getCurrentWord").andReturn("sample.txt")
editor.setText("sample.txt")
rootView.trigger 'fuzzy-finder:find-under-cursor'
openedPath = null
spyOn(rootView, "open").andCallFake (path) ->
openedPath = path
rootView.trigger 'fuzzy-finder:find-under-cursor'
waitsFor ->
openedPath != null
runs ->
expect(rootView.find('.fuzzy-finder')).not.toExist()
expect(finder).not.toBeVisible()
expect(openedPath).toBe "sample.txt"
describe "opening a path into a split", ->