-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmocha-shared.js
56 lines (44 loc) · 1 KB
/
mocha-shared.js
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
46
47
48
49
50
51
52
53
54
55
56
// https://github.com/mochajs/mocha/wiki/Shared-Behaviours
module.exports = describe => {
describe('User',
() => new User('tobi', 'holowaychuk'),
'behaves like a user'
)
describe('Admin',
() => new Admin('tobi', 'holowaychuk'),
'behaves like a user',
describe('should be an .admin',
user => user.admin,
it => it.equals(true)
)
)
describe.aspect('behaves like a user',
describe(
user => user.name.first,
it => it.equals('tobi')
),
describe(
user => user.name.last,
it => it.equals('holowaychuk')
),
describe(
user => user.fullname(),
it => it.equals('tobi holowaychuk')
)
)
}
function User (first, last) {
this.name = {
first: first,
last: last
}
}
User.prototype.fullname = function () {
return this.name.first + ' ' + this.name.last
}
function Admin (first, last) {
User.call(this, first, last)
this.admin = true
}
/* eslint no-proto: "off" */
Admin.prototype.__proto__ = User.prototype