       'text.plain.null-grammar'
     ])
 
-  it "should call savedCompiled", ->
-    atom.config.set("coffee-compile.compileOnSaveWithoutPreview", true)
-
-    waitsForPromise "coffee-compile package to activate", ->
-      atom.packages.activatePackage('coffee-compile')
-
     atom.workspaceView.attachToDom()
 
-    waitsForPromise "fixture file to open", ->
-      atom.workspace.open "coffee-compile-fixtures.coffee"
-
-    runs ->
-      atom.workspaceView.trigger "core:save"
-      expect(CoffeeCompileView.saveCompiled).toHaveBeenCalled()
-
-  it "should not call saveCompiled when option is disabled", ->
-    atom.config.set("coffee-compile.compileOnSaveWithoutPreview", false)
-
-    waitsForPromise "coffee-compile package to activate", ->
-      atom.packages.activatePackage('coffee-compile')
-
-    atom.workspaceView.attachToDom()
-
-    waitsForPromise "fixture file to open", ->
-      atom.workspace.open "coffee-compile-fixtures.coffee"
-
-    runs ->
-      atom.workspaceView.trigger "core:save"
-      expect(CoffeeCompileView.saveCompiled).not.toHaveBeenCalled()
-
-describe "CoffeeCompile compile on save", ->
-  beforeEach ->
-    atom.workspaceView = new WorkspaceView
-    atom.workspace     = atom.workspaceView.model
-
-    spyOn CoffeeCompileView, "saveCompiled"
     spyOn(CoffeeCompileView.prototype, "renderCompiled").andCallThrough()
 
-    waitsForPromise "coffee-compile package to activate", ->
-      atom.packages.activatePackage('coffee-compile')
+  describe "compile on save without preview", ->
+    beforeEach ->
+      spyOn CoffeeCompileView, "saveCompiled"
 
-    atom.workspaceView.attachToDom()
+    it "should call savedCompiled", ->
+      atom.config.set("coffee-compile.compileOnSaveWithoutPreview", true)
 
-    waitsForPromise "fixture file to open", ->
-      atom.workspace.open "coffee-compile-fixtures.coffee"
+      waitsForPromise "coffee-compile package to activate", ->
+        atom.packages.activatePackage('coffee-compile')
 
-  it "should call savedCompiled", ->
-    atom.config.set "coffee-compile.compileOnSave", true
+      waitsForPromise "fixture file to open", ->
+        atom.workspace.open "coffee-compile-fixtures.coffee"
 
-    runs ->
-      atom.workspaceView.getActiveView().trigger "coffee-compile:compile"
+      runs ->
+        atom.workspaceView.trigger "core:save"
+        expect(CoffeeCompileView.saveCompiled).toHaveBeenCalled()
 
-    waitsFor ->
-      CoffeeCompileView::renderCompiled.callCount > 0
+    it "should not call saveCompiled when option is disabled", ->
+      atom.config.set("coffee-compile.compileOnSaveWithoutPreview", false)
 
-    runs ->
-      expect(CoffeeCompileView.saveCompiled).toHaveBeenCalled()
+      waitsForPromise "coffee-compile package to activate", ->
+        atom.packages.activatePackage('coffee-compile')
 
-  it "should not call savedCompiled", ->
-    atom.config.set "coffee-compile.compileOnSave", false
+      waitsForPromise "fixture file to open", ->
+        atom.workspace.open "coffee-compile-fixtures.coffee"
 
-    runs ->
-      atom.workspaceView.getActiveView().trigger "coffee-compile:compile"
+      runs ->
+        atom.workspaceView.trigger "core:save"
+        expect(CoffeeCompileView.saveCompiled).not.toHaveBeenCalled()
 
-    waitsFor ->
-      CoffeeCompileView::renderCompiled.callCount > 0
+  describe "compile on save", ->
+    beforeEach ->
+      spyOn CoffeeCompileView, "saveCompiled"
 
-    runs ->
-      expect(CoffeeCompileView.saveCompiled).not.toHaveBeenCalled()
+      waitsForPromise "coffee-compile package to activate", ->
+        atom.packages.activatePackage('coffee-compile')
 
-describe "CoffeeCompile", ->
-  beforeEach ->
-    atom.workspaceView = new WorkspaceView
-    atom.workspace     = atom.workspaceView.model
-    spyOn(CoffeeCompileView.prototype, "renderCompiled").andCallThrough()
+      waitsForPromise "fixture file to open", ->
+        atom.workspace.open "coffee-compile-fixtures.coffee"
 
-    waitsForPromise "coffee-compile package to activate", ->
-      atom.packages.activatePackage('coffee-compile')
+    it "should call savedCompiled", ->
+      atom.config.set "coffee-compile.compileOnSave", true
 
-    waitsForPromise "language-coffee-script to activate", ->
-      atom.packages.activatePackage('language-coffee-script')
+      runs ->
+        atom.workspaceView.getActiveView().trigger "coffee-compile:compile"
 
-    atom.config.set('coffee-compile.grammars', [
-      'source.coffee'
-      'source.litcoffee'
-      'text.plain'
-      'text.plain.null-grammar'
-    ])
+      waitsFor ->
+        CoffeeCompileView::renderCompiled.callCount > 0
 
-  describe "should open a new pane", ->
+      runs ->
+        expect(CoffeeCompileView.saveCompiled).toHaveBeenCalled()
+
+    it "should not call savedCompiled", ->
+      atom.config.set "coffee-compile.compileOnSave", false
+
+      runs ->
+        atom.workspaceView.getActiveView().trigger "coffee-compile:compile"
+
+      waitsFor ->
+        CoffeeCompileView::renderCompiled.callCount > 0
+
+      runs ->
+        expect(CoffeeCompileView.saveCompiled).not.toHaveBeenCalled()
+
+  describe "open a new pane", ->
     beforeEach ->
-      atom.workspaceView.attachToDom()
+      waitsForPromise "coffee-compile package to activate", ->
+        atom.packages.activatePackage('coffee-compile')
 
       waitsForPromise "fixture file to open", ->
         atom.workspace.open "coffee-compile-fixtures.coffee"

CoffeeCompileView = require '../lib/coffee-compile-view'
{WorkspaceView} = require 'atom'

describe "CoffeeCompile compile on save without preview", ->
  beforeEach ->
    atom.workspaceView = new WorkspaceView
    atom.workspace     = atom.workspaceView.model
    spyOn CoffeeCompileView, "saveCompiled"

    waitsForPromise "language-coffee-script to activate", ->
      atom.packages.activatePackage('language-coffee-script')

  describe "focus editor after compile", ->
    beforeEach ->
      atom.config.set "coffee-compile.focusEditorAfterCompile", true

      waitsForPromise "coffee-compile package to activate", ->
        atom.packages.activatePackage('coffee-compile')

      waitsForPromise ->
        atom.workspace.open "test.coffee"
