'use babel'

/* @flow */

import { Point } from 'atom'
import { getMessage } from './common'
import * as Helpers from '../lib/helpers'

describe('Helpers', function() {
  describe('showError', function() {
    it('shows notifications properly', function() {
      expect(atom.notifications.getNotifications().length).toBe(0)
      Helpers.showError(new Error('Hello'))
      expect(atom.notifications.getNotifications().length).toBe(1)
      Helpers.showError(new Error('Hello'))
      expect(atom.notifications.getNotifications().length).toBe(2)
    })
  })

  describe('shouldTriggerLinter', function() {
    it('triggers a normal linter only on save', function() {
      const provider = {
        lintOnFly: false,
        grammarScopes: ['source.js']
      }
      expect(provider, true, ['source.js']).toBe(false)
      expect(provider, false, ['source.js']).toBe(true)
    })
    it('triggers on fly ones in both scenarios', function() {
      const provider = {
        lintOnFly: true,
        grammarScopes: ['source.js']
      }
      expect(provider, true, ['source.js']).toBe(true)
      expect(provider, false, ['source.js']).toBe(true)
    })
    it('only triggers if scope matches', function() {
      const provider = {
        lintOnFly: false,
        grammarScopes: ['source.js']
      }
      expect(provider, false, ['source.js']).toBe(true)
      expect(provider, false, ['source.php']).toBe(false)
    })
  })

  describe('messageKey', function() {
    it('works', function() {
      expect(function() {
        Helpers.messageKey(getMessage('Error'))
      }).not.toThrow()
    })
    it('works with mixed arrays and points in ranges', function() {
      expect(function() {
        const message = getMessage('Error')
        message.range = [new Point(1, 0), new Point(1, 1)]
        Helpers.messageKey(message)
      }).not.toThrow()
    })
  })
})

@@ -762,32 +762,60 @@
  %7D%0A      expect(
+Helpers.shouldTriggerLinter(
 provider, true, 
@@ -824,24 +824,25 @@
 source.js'%5D)
+)
 .toBe(false)
@@ -847,32 +847,60 @@
 e)%0A      expect(
+Helpers.shouldTriggerLinter(
 provider, false,
@@ -906,32 +906,33 @@
 , %5B'source.js'%5D)
+)
 .toBe(true)%0A    
@@ -1096,32 +1096,60 @@
  %7D%0A      expect(
+Helpers.shouldTriggerLinter(
 provider, true, 
@@ -1154,32 +1154,33 @@
 , %5B'source.js'%5D)
+)
 .toBe(true)%0A    
@@ -1180,32 +1180,60 @@
 e)%0A      expect(
+Helpers.shouldTriggerLinter(
 provider, false,
@@ -1239,32 +1239,33 @@
 , %5B'source.js'%5D)
+)
 .toBe(true)%0A    
@@ -1422,32 +1422,60 @@
  %7D%0A      expect(
+Helpers.shouldTriggerLinter(
 provider, false,
@@ -1489,16 +1489,17 @@
 ce.js'%5D)
+)
 .toBe(tr
@@ -1515,16 +1515,44 @@
  expect(
+Helpers.shouldTriggerLinter(
 provider
@@ -1575,16 +1575,17 @@
 e.php'%5D)
+)
 .toBe(fa

Fix typos in specs