     it "includes completions for the scope's completion preferences", ->
       runs ->
         editor.moveToEndOfLine()
-        editor.insertText "o"
-        editor.insertText "u"
-        editor.insertText "t"
-
-        advanceClock completionDelay
-
-        autocompleteView = atom.views.getView(autocompleteManager)
-        items = autocompleteView.querySelectorAll("li")
-        expect(editorView.querySelector(".autocomplete-plus")).toExist()
-        expect(items.length).toBe 10
-        expect(items[0]).toHaveText "outline"
-        expect(items[1]).toHaveText "outline-color"
-        expect(items[2]).toHaveText "outline-width"
-        expect(items[3]).toHaveText "outline-style"
+        editor.insertText('o')
+        editor.insertText('u')
+        editor.insertText('t')
+
+        advanceClock(completionDelay)
+
+        autocompleteView = atom.views.getView(autocompleteManager)
+        items = autocompleteView.querySelectorAll('li')
+        expect(editorView.querySelector('.autocomplete-plus')).toExist()
+        expect(items.length).toBe(10)
+        expect(items[0]).toHaveText('outline')
+        expect(items[1]).toHaveText('outline-color')
+        expect(items[2]).toHaveText('outline-width')
+        expect(items[3]).toHaveText('outline-style')
 
   describe "when auto-activation is disabled", ->
     beforeEach ->
       runs ->
-        atom.config.set "autocomplete-plus.enableAutoActivation", false
-
-      waitsForPromise -> atom.workspace.open("sample.js").then (e) ->
+        atom.config.set('autocomplete-plus.enableAutoActivation', false)
+
+      waitsForPromise -> atom.workspace.open('sample.js').then (e) ->
         editor = e
 
       # Activate the package
-      waitsForPromise -> atom.packages.activatePackage("autocomplete-plus").then (a) ->
+      waitsForPromise -> atom.packages.activatePackage('autocomplete-plus').then (a) ->
         mainModule = a.mainModule
         autocompleteManager = mainModule.autocompleteManagers[0]
 
       runs ->
 
     it "does not show suggestions after a delay", ->
-      triggerAutocompletion editor
-      advanceClock completionDelay
+      triggerAutocompletion(editor)
+      advanceClock(completionDelay)
       expect(editorView.querySelector(".autocomplete-plus")).not.toExist()
 
     it "shows suggestions when explicitly triggered", =>
-      triggerAutocompletion editor
-      advanceClock completionDelay
-
-      editorView = atom.views.getView(editor);
-      expect(editorView.querySelector(".autocomplete-plus")).not.toExist()
-      atom.commands.dispatch editorView, "autocomplete-plus:activate"
-      expect(editorView.querySelector(".autocomplete-plus")).toExist()
+      triggerAutocompletion(editor)
+      advanceClock(completionDelay)
+
+      editorView = atom.views.getView(editor)
+      expect(editorView.querySelector('.autocomplete-plus')).not.toExist()
+      atom.commands.dispatch(editorView, 'autocomplete-plus:activate')
+      expect(editorView.querySelector('.autocomplete-plus')).toExist()
 
   describe "HTML label support", ->
     beforeEach ->
-      waitsForPromise -> atom.workspace.open("sample.js").then (e) ->
+      waitsForPromise -> atom.workspace.open('sample.js').then (e) ->
         editor = e
 
       # Activate the package
-      waitsForPromise -> atom.packages.activatePackage("autocomplete-plus").then (a) ->
+      waitsForPromise -> atom.packages.activatePackage('autocomplete-plus').then (a) ->
         mainModule = a.mainModule
         autocompleteManager = mainModule.autocompleteManagers[0]
 

  beforeEach ->
    runs ->
      # Set to live completion
      atom.config.set "autocomplete-plus.enableAutoActivation", true
      atom.config.set "editor.fontSize", "16"

      # Set the completion delay
      completionDelay = 100
      atom.config.set "autocomplete-plus.autoActivationDelay", completionDelay
      completionDelay += 100 # Rendering

      workspaceElement = atom.views.getView(atom.workspace)


    describe "on changed events", ->
      it "should show the suggestion list when suggestions are found", ->
        expect(editorView.querySelector('.autocomplete-plus')).not.toExist()

        # Trigger an autocompletion
        triggerAutocompletion(editor)
        advanceClock(completionDelay)
        expect(editorView.querySelector('.autocomplete-plus')).toExist()

        # Check suggestions
        suggestions = ['function', 'if', 'left', 'shift']
        [].forEach.call editorView.querySelectorAll('.autocomplete-plus li span'), (item, index) ->
          expect(item.innerText).toEqual(suggestions[index])

      it "should not show the suggestion list when no suggestions are found", ->
        expect(editorView.querySelector('.autocomplete-plus')).not.toExist()

        # Trigger an autocompletion
        editor.moveToBottom()
        editor.insertText('x')
        advanceClock(completionDelay)
        expect(editorView.querySelector('.autocomplete-plus')).not.toExist()

      it "should show the suggestion list when backspacing", ->
        expect(editorView.querySelector('.autocomplete-plus')).not.toExist()

        # Trigger an autocompletion
        editor.moveToBottom()
        editor.insertText('fu')
        advanceClock(completionDelay)
        key = atom.keymaps.constructor.keydownEvent('backspace', target: editorView)
        atom.keymaps.handleKeyboardEvent(key)
        advanceClock(completionDelay)

        expect(editorView.querySelector(".autocomplete-plus")).toExist()
        expect(editor.lineTextForBufferRow(13)).toBe('f')

      it "should not update the suggestion list while composition is in progress", ->
        triggerAutocompletion(editor)
        advanceClock(completionDelay)

        autocompleteView = atom.views.getView(autocompleteManager)

