 
         editorView.dispatchEvent(buildIMECompositionEvent('compositionstart', target: editorView))
         editorView.dispatchEvent(buildIMECompositionEvent('compositionupdate', data: "~", target: editorView))
-        advanceClock completionDelay
+        advanceClock(completionDelay)
 
         expect(autocompleteManager.changeItems).not.toHaveBeenCalled()
 
         editorView.dispatchEvent(buildIMECompositionEvent('compositionend', target: editorView))
         editorView.firstChild.dispatchEvent(buildTextInputEvent(data: 'ã', target: editorView))
 
-        expect(editor.lineTextForBufferRow(13)).toBe 'fã'
+        expect(editor.lineTextForBufferRow(13)).toBe('fã')
 
     describe "accepting suggestions", ->
       it "hides the suggestions list when a suggestion is confirmed", ->
-        expect(editorView.querySelector(".autocomplete-plus")).not.toExist()
+        expect(editorView.querySelector('.autocomplete-plus')).not.toExist()
 
         # Trigger an autocompletion
         editor.moveToBottom()
         editor.moveToBeginningOfLine()
-        editor.insertText("f")
-        advanceClock completionDelay
-        expect(editorView.querySelector(".autocomplete-plus")).toExist()
-
-        # Accept suggestion
-        autocompleteView = atom.views.getView(autocompleteManager)
-        atom.commands.dispatch(autocompleteView, "autocomplete-plus:confirm")
-
-        expect(editorView.querySelector(".autocomplete-plus")).not.toExist()
+        editor.insertText('f')
+        advanceClock(completionDelay)
+        expect(editorView.querySelector('.autocomplete-plus')).toExist()
+
+        # Accept suggestion
+        autocompleteView = atom.views.getView(autocompleteManager)
+        atom.commands.dispatch(autocompleteView, 'autocomplete-plus:confirm')
+
+        expect(editorView.querySelector('.autocomplete-plus')).not.toExist()
 
       describe "when tab is used to accept suggestions", ->
         beforeEach ->
           atom.config.set('autocomplete-plus.confirmCompletion', 'tab')
 
         it "inserts the word and moves the cursor to the end of the word", ->
-          expect(editorView.querySelector(".autocomplete-plus")).not.toExist()
+          expect(editorView.querySelector('.autocomplete-plus')).not.toExist()
 
           # Trigger an autocompletion
-          triggerAutocompletion editor
-          advanceClock completionDelay
+          triggerAutocompletion(editor)
+          advanceClock(completionDelay)
 
           autocompleteView = atom.views.getView(autocompleteManager)
           # Accept suggestion

{triggerAutocompletion, buildIMECompositionEvent, buildTextInputEvent} = require "./spec-helper"
_ = require "underscore-plus"
{KeymapManager} = require 'atom'
TestProvider = require "./lib/test-provider"

describe "Autocomplete", ->
  [completionDelay, editorView, editor, autocompleteManager, mainModule] = []


  describe "when auto-activation is enabled", ->
    beforeEach ->
      runs -> atom.config.set('autocomplete-plus.enableAutoActivation', true)

      waitsForPromise -> atom.workspace.open('sample.js').then (e) ->
        editor = e

      # Activate the package
      waitsForPromise -> atom.packages.activatePackage('autocomplete-plus').then (a) ->
        mainModule = a.mainModule
        autocompleteManager = mainModule.autocompleteManagers[0]

