mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge branch 'master' of github.com:github/atom
This commit is contained in:
@@ -17,20 +17,15 @@ describe "Autocomplete", ->
|
||||
afterEach ->
|
||||
autocomplete.remove()
|
||||
|
||||
describe 'autocomplete:toggle event', ->
|
||||
describe 'autocomplete:show event', ->
|
||||
it "shows autocomplete view and focuses its mini-editor", ->
|
||||
expect($(document).find('#autocomplete')).not.toExist()
|
||||
|
||||
editor.trigger "autocomplete:toggle"
|
||||
editor.trigger "autocomplete:attach"
|
||||
expect($(document).find('#autocomplete')).toExist()
|
||||
expect(autocomplete.editor.isFocused).toBeFalsy()
|
||||
expect(autocomplete.miniEditor.isFocused).toBeTruthy()
|
||||
|
||||
miniEditor.trigger "autocomplete:toggle"
|
||||
expect($(document).find('#autocomplete')).not.toExist()
|
||||
expect(autocomplete.editor.isFocused).toBeTruthy()
|
||||
expect(autocomplete.miniEditor.isFocused).toBeFalsy()
|
||||
|
||||
describe "when no text is selected", ->
|
||||
it 'autocompletes word when there is only a prefix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:s:extra")
|
||||
@@ -186,7 +181,19 @@ describe "Autocomplete", ->
|
||||
expect(autocomplete.find('li:eq(0)')).toHaveClass('selected')
|
||||
expect(autocomplete.find('li:eq(1)')).not.toHaveClass('selected')
|
||||
|
||||
describe "when the mini-editor receives text input", ->
|
||||
describe "when the mini-editor's buffer changes", ->
|
||||
describe "when text is removed from the mini-editor", ->
|
||||
it "reloads the match list based on the mini-editor's text", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
editor.setCursorBufferPosition([10,0])
|
||||
autocomplete.attach()
|
||||
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 8
|
||||
miniEditor.textInput('c')
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 3
|
||||
miniEditor.backspace()
|
||||
expect(autocomplete.matchesList.find('li').length).toBe 8
|
||||
|
||||
describe "when the text contains only word characters", ->
|
||||
it "narrows the list of completions with the fuzzy match algorithm", ->
|
||||
editor.buffer.insert([10,0] ,"t")
|
||||
|
||||
@@ -51,6 +51,20 @@ describe "Editor", ->
|
||||
expect(newEditor.editSessions[0]).toEqual(editor.editSessions[0])
|
||||
expect(newEditor.editSessions[0]).not.toBe(editor.editSessions[0])
|
||||
|
||||
describe "editor-open event", ->
|
||||
it 'only triggers an editor-open event when it is first added to the DOM', ->
|
||||
openHandler = jasmine.createSpy('openHandler')
|
||||
editor.on 'editor-open', openHandler
|
||||
|
||||
editor.simulateDomAttachment()
|
||||
expect(openHandler).toHaveBeenCalled()
|
||||
[event, eventEditor] = openHandler.argsForCall[0]
|
||||
expect(eventEditor).toBe editor
|
||||
|
||||
openHandler.reset()
|
||||
editor.simulateDomAttachment()
|
||||
expect(openHandler).not.toHaveBeenCalled()
|
||||
|
||||
describe "text rendering", ->
|
||||
it "creates a line element for each line in the buffer with the html-escaped text of the line", ->
|
||||
expect(editor.lines.find('.line').length).toEqual(buffer.numLines())
|
||||
|
||||
Reference in New Issue
Block a user