1 | require('es6-promise').polyfill()
|
2 |
|
3 | if typeof window isnt 'undefined'
|
4 | root = window
|
5 | else
|
6 | root = global
|
7 |
|
8 | if !root._spec_setup
|
9 | root.sinon = require 'sinon'
|
10 | root.chai = require 'chai'
|
11 | root.expect = chai.expect
|
12 | root.sandbox = sinon.sandbox.create()
|
13 |
|
14 | sinonChai = require 'sinon-chai'
|
15 | isSinonChaiIncludedAsBrowserPackage = typeof sinonChai is 'function'
|
16 | if isSinonChaiIncludedAsBrowserPackage
|
17 | chai.use sinonChai
|
18 | root._spec_setup = true
|
19 |
|
20 |
|
21 | beforeEach ->
|
22 | root.eventric = require './'
|
23 |
|
24 |
|
25 | afterEach ->
|
26 |
|
27 | moduleFilenames = Object.keys require.cache
|
28 | areSpecsRunningInBrowser = window?
|
29 | if areSpecsRunningInBrowser
|
30 | moduleFilenames.forEach (filename) ->
|
31 | delete require.cache[filename]
|
32 | else
|
33 | moduleFilenames.forEach (filename) ->
|
34 | isSourceFile = filename.indexOf('src/') > 1
|
35 | isEventricPlugin = /node_modules\/eventric-/i.test filename
|
36 | if isSourceFile or isEventricPlugin
|
37 | delete require.cache[filename]
|
38 | sandbox.restore()
|