         expect(codewarsElement).toBeVisible()
         atom.commands.dispatch workspaceElement, 'codewars:toggle'
         expect(codewarsElement).not.toBeVisible()
+
+    it "hides the view when blurred", ->
+      jasmine.attachToDOM(workspaceElement)
+
+      expect(workspaceElement.querySelector('.codewars')).not.toExist()
+
+      atom.commands.dispatch workspaceElement, 'codewars:toggle'
+
+      waitsForPromise ->
+        activationPromise
+
+      runs ->
+        # Now we can test for view visibility
+        codewarsElement = workspaceElement.querySelector('.codewars')
+        expect(codewarsElement).toBeVisible()
+        $(workspaceElement).triggerHandler('click')
+        expect(codewarsElement).not.toBeVisible()
+
+    it "hides the view when deactivated", ->
+      jasmine.attachToDOM(workspaceElement)
+
+      expect(workspaceElement.querySelector('.codewars')).not.toExist()
+
+      atom.commands.dispatch workspaceElement, 'codewars:toggle'
+
+      waitsForPromise ->
+        activationPromise
+
+      runs ->
+        # Now we can test for view visibility
+        codewarsElement = workspaceElement.querySelector('.codewars')
+        expect(codewarsElement).toBeVisible()
+        atom.commands.dispatch workspaceElement, 'core:cancel'
+        expect(codewarsElement).not.toBeVisible()

Codewars = require '../lib/codewars'

# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
#

        codewarsElement = workspaceElement.querySelector('.codewars')
        expect(codewarsElement).toExist()

        codewarsView = $(codewarsElement).view()
        expect(codewarsView).toBeInstanceOf(View)

        expect(codewarsView.isVisible()).toBe true
        atom.commands.dispatch workspaceElement, 'codewars:toggle'
        expect(codewarsView.isVisible()).toBe false

    it "hides and shows the view", ->
      # This test shows you an integration test testing at the view level.
