-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.spec.coffee
45 lines (34 loc) · 1.17 KB
/
main.spec.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
sinon = require('sinon')
chai = require('chai')
chai.use require('chai-as-promised')
chai.use require('sinon-chai')
chai.should()
describe "main", ->
temp = require('temp').track()
sio = require('socket.io')
express = require('express')
extensions = require('./lib/extensions')
watcher = require('./lib/watcher')
{EventEmitter} = require('events')
config = require('config')
main = require('./main')
app = null
sandbox = null
beforeEach ->
sandbox = sinon.sandbox.create()
app = express()
sandbox.spy(temp, 'mkdir')
sandbox.spy(extensions, 'loadExtensions')
sandbox.stub(watcher, 'startWatching').returns new EventEmitter()
sandbox.stub(app, 'listen')
sandbox.stub(sio, 'listen').returns {set: ->}
afterEach ->
sandbox.restore()
describe "init", ->
it "should create a temp dir for storing generated crx files", ->
main.init(app).then ->
temp.mkdir.should.have.been.calledWith('kitt-extensions')
it "should load all extensions", ->
main.init(app).then ->
extensions.loadExtensions.should.have.been.calledWith(
config.extensions.root, sinon.match.string, config.extensions.privateKey)