mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
💄
This commit is contained in:
@@ -11,33 +11,33 @@ describe "Autocomplete", ->
|
||||
editor.setBuffer new Buffer(require.resolve('fixtures/sample.js'))
|
||||
autocomplete = new Autocomplete(editor)
|
||||
|
||||
describe '.matches(prefix, suffix)', ->
|
||||
it 'returns matches on buffer starting with given prefix and ending with given suffix', ->
|
||||
matches = autocomplete.matches("s", "").map (match) -> match[0]
|
||||
expect(matches.length).toBe 2
|
||||
expect(matches).toContain("sort")
|
||||
expect(matches).toContain("shift")
|
||||
describe '.wordMatches(prefix, suffix)', ->
|
||||
it 'returns wordMatches on buffer starting with given prefix and ending with given suffix', ->
|
||||
wordMatches = autocomplete.wordMatches("s", "").map (match) -> match[0]
|
||||
expect(wordMatches.length).toBe 2
|
||||
expect(wordMatches).toContain("sort")
|
||||
expect(wordMatches).toContain("shift")
|
||||
|
||||
matches = autocomplete.matches("l", "t").map (match) -> match[0]
|
||||
expect(matches.length).toBe 1
|
||||
expect(matches).toContain("left")
|
||||
wordMatches = autocomplete.wordMatches("l", "t").map (match) -> match[0]
|
||||
expect(wordMatches.length).toBe 1
|
||||
expect(wordMatches).toContain("left")
|
||||
|
||||
it 'ignores case when finding matches', ->
|
||||
matches = autocomplete.matches("S", "").map (match) -> match[0]
|
||||
expect(matches.length).toBe 2
|
||||
expect(matches).toContain("sort")
|
||||
expect(matches).toContain("shift")
|
||||
wordMatches = autocomplete.wordMatches("S", "").map (match) -> match[0]
|
||||
expect(wordMatches.length).toBe 2
|
||||
expect(wordMatches).toContain("sort")
|
||||
expect(wordMatches).toContain("shift")
|
||||
|
||||
matches = autocomplete.matches("l", "t").map (match) -> match[0]
|
||||
expect(matches.length).toBe 1
|
||||
expect(matches).toContain("left")
|
||||
wordMatches = autocomplete.wordMatches("l", "t").map (match) -> match[0]
|
||||
expect(wordMatches.length).toBe 1
|
||||
expect(wordMatches).toContain("left")
|
||||
|
||||
describe ".completeWordAtEditorCursorPosition()", ->
|
||||
describe ".completeWord()", ->
|
||||
describe "when no text is selected", ->
|
||||
it 'autocompletes word when there is only a prefix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:s:extra")
|
||||
editor.setCursorBufferPosition([10,7])
|
||||
autocomplete.completeWordAtEditorCursorPosition()
|
||||
autocomplete.completeWord()
|
||||
|
||||
expect(editor.lineForBufferRow(10)).toBe "extra:sort:extra"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10,10]
|
||||
@@ -46,7 +46,7 @@ describe "Autocomplete", ->
|
||||
it 'autocompletes word when there is only a suffix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:e:extra")
|
||||
editor.setCursorBufferPosition([10,6])
|
||||
autocomplete.completeWordAtEditorCursorPosition()
|
||||
autocomplete.completeWord()
|
||||
|
||||
expect(editor.lineForBufferRow(10)).toBe "extra:while:extra"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10,10]
|
||||
@@ -55,7 +55,7 @@ describe "Autocomplete", ->
|
||||
it 'autocompletes word when there is a prefix and suffix', ->
|
||||
editor.buffer.insert([8,43] ,"q")
|
||||
editor.setCursorBufferPosition([8,44])
|
||||
autocomplete.completeWordAtEditorCursorPosition()
|
||||
autocomplete.completeWord()
|
||||
|
||||
expect(editor.lineForBufferRow(8)).toBe " return sort(left).concat(pivot).concat(quicksort(right));"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [8,48]
|
||||
@@ -65,7 +65,7 @@ describe "Autocomplete", ->
|
||||
it 'autocompletes word when there is only a prefix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:sort:extra")
|
||||
editor.setSelectionBufferRange [[10,7], [10,10]]
|
||||
autocomplete.completeWordAtEditorCursorPosition()
|
||||
autocomplete.completeWord()
|
||||
|
||||
expect(editor.lineForBufferRow(10)).toBe "extra:shift:extra"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10,11]
|
||||
@@ -74,7 +74,7 @@ describe "Autocomplete", ->
|
||||
it 'autocompletes word when there is only a suffix', ->
|
||||
editor.buffer.insert([10,0] ,"extra:current:extra")
|
||||
editor.setSelectionBufferRange [[10,6],[10,12]]
|
||||
autocomplete.completeWordAtEditorCursorPosition()
|
||||
autocomplete.completeWord()
|
||||
|
||||
expect(editor.lineForBufferRow(10)).toBe "extra:quicksort:extra"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [10,14]
|
||||
@@ -82,7 +82,7 @@ describe "Autocomplete", ->
|
||||
|
||||
it 'autocompletes word when there is a prefix and suffix', ->
|
||||
editor.setSelectionBufferRange [[5,7],[5,12]]
|
||||
autocomplete.completeWordAtEditorCursorPosition()
|
||||
autocomplete.completeWord()
|
||||
|
||||
expect(editor.lineForBufferRow(5)).toBe " concat = items.shift();"
|
||||
expect(editor.getCursorBufferPosition()).toEqual [5,11]
|
||||
|
||||
Reference in New Issue
Block a user