 
   beforeEach ->
     atom.workspaceView = new WorkspaceView
-    editorView = new EditorView(editor: atom.project.openSync('sample.js'))
-    {editor} = editorView
-    autocomplete = new AutocompleteView(editorView)
-    miniEditor = autocomplete.filterEditorView
+
+    waitsForPromise ->
+      atom.workspace.open('sample.js').then (editor) ->
+        editorView = new EditorView({editor})
+
+    runs ->
+      {editor} = editorView
+      autocomplete = new AutocompleteView(editorView)
+      miniEditor = autocomplete.filterEditorView
 
   describe 'autocomplete:toggle event', ->
     it "shows autocomplete view and focuses its mini-editor", ->


  beforeEach ->
    atom.workspaceView = new WorkspaceView
    atom.workspaceView.openSync('sample.js')
    atom.workspaceView.simulateDomAttachment()
    activationPromise = atom.packages.activatePackage('autocomplete')

  describe "@activate()", ->
    it "activates autocomplete on all existing and future editors (but not on autocomplete's own mini editor)", ->

    expect(autocomplete.list.prop('scrollWidth')).toBe autocomplete.list.width()

  it "includes completions for the scope's completion preferences", ->
    cssEditorView = null

    waitsForPromise ->
      atom.packages.activatePackage('language-css')

    waitsForPromise ->
      atom.workspace.open('css.css').then (editor) ->
        cssEditorView = new EditorView({editor})

    runs ->
      cssEditor = cssEditorView.editor
      autocomplete = new AutocompleteView(cssEditorView)

