'use babel'

import {ProvidersList} from '../lib/providers-list'

describe('ProvidersList', function() {
  let providersList

  beforeEach(function() {
    if (providersList) {
      providersList.dispose()
    }
    providersList = new ProvidersList()
  })

  describe('addProvider', function() {
    it('validates parameters properly', function() {
      expect(function() {
        providersList.addProvider()
      }).toThrow()
      expect(function() {
        providersList.addProvider(null)
      }).toThrow()
      expect(function() {
        providersList.addProvider(1)
      }).toThrow()
      expect(function() {
        providersList.addProvider(false)
      }).toThrow()
      expect(function() {
        providersList.addProvider(true)
      }).toThrow()

      expect(function() {
        providersList.addProvider({
          grammarScopes: false
        })
      }).toThrow()
      expect(function() {
        providersList.addProvider({
          grammarScopes: null
        })
      }).toThrow()
      expect(function() {
        providersList.addProvider({
          grammarScopes: true
        })
      }).toThrow()
      expect(function() {
        providersList.addProvider({
          grammarScopes: 5
        })
      }).toThrow()

      expect(function() {
        providersList.addProvider({
          grammarScopes: [],
          getIntentions: false
        })
      }).toThrow()
      expect(function() {
        providersList.addProvider({
          grammarScopes: [],
          getIntentions: null
        })
      }).toThrow()
      expect(function() {
        providersList.addProvider({
          grammarScopes: [],
          getIntentions: true
        })
      }).toThrow()
      expect(function() {
        providersList.addProvider({
          grammarScopes: [],
          getIntentions: 20
        })
      }).toThrow()
      providersList.addProvider({
        grammarScopes: [],
        getIntentions: function() {}
      })
    })
  })
})

@@ -1973,11 +1973,986 @@
 %7D)%0A  %7D)%0A
+  describe('hasProvider', function() %7B%0A    it('works properly', function() %7B%0A      const provider = %7B%0A        grammarScopes: %5B%5D,%0A        getIntentions: function() %7B%7D%0A      %7D%0A      expect(providersList.hasProvider(provider)).toBe(false)%0A      providersList.addProvider(provider)%0A      expect(providersList.hasProvider(provider)).toBe(true)%0A    %7D)%0A  %7D)%0A  describe('deleteProvider', function() %7B%0A    it('works properly', function() %7B%0A      providersList.deleteProvider(true)%0A      providersList.deleteProvider(null)%0A      providersList.deleteProvider(false)%0A      providersList.deleteProvider(50)%0A      const provider = %7B%0A        grammarScopes: %5B%5D,%0A        getIntentions: function() %7B%7D%0A      %7D%0A      expect(providersList.hasProvider(provider)).toBe(false)%0A      providersList.addProvider(provider)%0A      expect(providersList.hasProvider(provider)).toBe(true)%0A      providersList.deleteProvider(provider)%0A      expect(providersList.hasProvider(provider)).toBe(false)%0A    %7D)%0A  %7D)%0A
 %7D)%0A

Add providers-list specs for hasProvider and deleteProvider