Manual Reference Source Test

test/Context.spec.js

  1. // Import the necessary modules.
  2. // @flow
  3. /* eslint-disable no-unused-expressions */
  4. import { expect } from 'chai'
  5.  
  6. import {
  7. Context,
  8. IProvider
  9. } from '../src'
  10.  
  11. /** @test {Context} */
  12. describe('Context', () => {
  13. /**
  14. * The context object to test
  15. * @type {Context}
  16. */
  17. let context: Context
  18.  
  19. /**
  20. * Hook for setting up the Context tests.
  21. * @type {Function}
  22. */
  23. before(() => {
  24. context = new Context()
  25. })
  26.  
  27. /** @test {Context#execute} */
  28. it('should throw an error when executing the default provider', () => {
  29. expect(context.execute.bind(context)).to
  30. .throw('Using default method: \'scrapeConfigs\'')
  31. })
  32.  
  33. /** @test {Context#provider} */
  34. it('should check if Context has a provider', () => {
  35. const current = context.provider
  36. const iProvider = new IProvider()
  37. context.provider = iProvider
  38.  
  39. expect(context.provider).to.not.equal(current)
  40. expect(context.provider).to.equal(iProvider)
  41. })
  42. })