UNPKG

1.08 kBtext/coffeescriptView Raw
1require('es6-promise').polyfill()
2
3if typeof window isnt 'undefined'
4 root = window
5else
6 root = global
7
8if !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
21beforeEach ->
22 root.eventric = require './'
23
24
25afterEach ->
26 # TODO: Implement proper destroy() functionality on eventric so this cleanup can be removed
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()