       runs ->
         expect(util.compileToFile).toHaveBeenCalled()
 
-    it "should not call util.compileToFile", ->
-      atom.config.set "coffee-compile.compileOnSave", false
+    it 'should not call util.compileToFile', ->
+      atom.config.set 'coffee-compile.compileOnSave', false
 
       runs ->
-        atom.workspaceView.getActiveView().trigger "coffee-compile:compile"
+        atom.workspaceView.getActiveView().trigger 'coffee-compile:compile'
         expect(util.compileToFile).not.toHaveBeenCalled()
 
-  describe "open a new pane", ->
+  describe 'open a new pane', ->
     beforeEach ->
       runs ->
-        atom.workspaceView.getActiveView().trigger "coffee-compile:compile"
+        atom.workspaceView.getActiveView().trigger 'coffee-compile:compile'
 
-      waitsFor "renderCompiled to be called", ->
+      waitsFor 'renderCompiled to be called', ->
         CoffeeCompileView::renderCompiled.callCount > 0
 
-    it "should always split to the right", ->
+    it 'should always split to the right', ->
       runs ->
         expect(atom.workspaceView.getPaneViews()).toHaveLength 2
         [editorPane, compiledPane] = atom.workspaceView.getPaneViews()


        compiled = compiledPane.getActiveItem()

    it "should focus on compiled pane", ->
      runs ->
        [editorPane, compiledPane] = atom.workspaceView.getPaneViews()
        expect(compiledPane).toHaveFocus()

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

    it "should focus editor when option is set", ->
      runs ->
        atom.workspaceView.getActiveView().trigger "coffee-compile:compile"

      waitsFor ->
        CoffeeCompileView::renderCompiled.callCount > 0

      runs ->
        [editorPane, compiledPane] = atom.workspaceView.getPaneViews()
        expect(editorPane).toHaveFocus()

  describe "when the editor's grammar is not coffeescript", ->
    it "should not preview compiled js", ->
      atom.config.set "coffee-compile.grammars", []

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

      waitsForPromise ->
        atom.workspace.open "coffee-compile-fixtures.coffee"

      runs ->
        spyOn(atom.workspace, "open").andCallThrough()
        atom.workspaceView.getActiveView().trigger 'markdown-preview:show'
        expect(atom.workspace.open).not.toHaveBeenCalled()

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

describe 'CoffeeCompile', ->
  editor = null

  beforeEach ->
    atom.workspaceView = new WorkspaceView
    atom.workspace     = atom.workspaceView.model

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

    waitsForPromise ->
      atom.packages.activatePackage 'coffee-compile'

    waitsForPromise ->
      atom.workspace.open('coffee-compile-fixtures.coffee').then (o) ->
