1
|
|
|
/* eslint-env mocha */ |
2
|
|
|
|
3
|
|
|
var Chai = require('chai') |
4
|
|
|
var expect = Chai.expect |
5
|
|
|
|
6
|
|
|
var CallEvents = require('../../../../lib/Stub/CallEvents').CallEvents |
7
|
|
|
|
8
|
|
|
describe('Acceptance', function () { |
9
|
|
|
describe('/Stub', function () { |
10
|
|
|
describe('/CallEvents.js', function () { |
11
|
|
|
describe('.CallEvents', function () { |
12
|
|
|
Object.keys(CallEvents).forEach(function (name) { |
13
|
|
|
describe('.' + name, function () { |
14
|
|
|
describe('< new', function () { |
15
|
|
|
var Event = CallEvents[name] |
16
|
|
|
it('creates ' + name + ' without any passed properties', function () { |
17
|
|
|
var lambda = function () { |
18
|
|
|
return new Event() |
19
|
|
|
} |
20
|
|
|
expect(lambda).not.to.throw() |
21
|
|
|
}) |
22
|
|
|
|
23
|
|
|
CallEvents[name]._properties.forEach(function (property) { |
24
|
|
|
it('provides default value for property `' + property + '`', function () { |
25
|
|
|
expect(new Event()).to.have.property(property) |
26
|
|
|
}) |
27
|
|
|
|
28
|
|
|
it('sets property `' + property + '`', function () { |
29
|
|
|
var input = {} |
30
|
|
|
var value = {x: 12} |
31
|
|
|
input[property] = value |
32
|
|
|
var event = new Event(input) |
33
|
|
|
expect(event).to.have.property(property).eq(value) |
34
|
|
|
}) |
35
|
|
|
}) |
36
|
|
|
|
37
|
|
|
it('doesn\'t set `name` property', function () { |
38
|
|
|
var value = {x: 12} |
39
|
|
|
var event = new Event({name: value}) |
40
|
|
|
expect(event.name).not.to.eq(value) |
41
|
|
|
}) |
42
|
|
|
|
43
|
|
|
it('sets arbitrary property', function () { |
44
|
|
|
var value = {x: 12} |
45
|
|
|
var property = 'wharrgarbl' |
46
|
|
|
var input = {} |
47
|
|
|
input[property] = value |
48
|
|
|
expect(new Event(input)).to.have.property(property).eq(value) |
49
|
|
|
}) |
50
|
|
|
}) |
51
|
|
|
}) |
52
|
|
|
}) |
53
|
|
|
}) |
54
|
|
|
}) |
55
|
|
|
}) |
56
|
|
|
}) |
57
|
|
|
|