-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
61 lines (52 loc) · 1.41 KB
/
test.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
57
58
59
60
61
/*!
* dush-methods <https://github.com/tunnckoCore/dush-methods>
*
* Copyright (c) Charlike Mike Reagent <@tunnckoCore> (https://i.am.charlike.online)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
var test = require('mukla')
var dush = require('dush')
var methods = require('./index')
var emitter = dush().use(methods())
test('should add `.define` and `.delegate` methods to dush', function (done) {
var app = dush()
app.use(methods())
test.strictEqual(typeof app.define, 'function')
test.strictEqual(typeof app.delegate, 'function')
done()
})
test('should `.define` property to `app` instance', function (done) {
emitter.use(methods())
emitter.define('foo', 123)
test.strictEqual(emitter.foo, 123)
done()
})
test('should delegate properties to `app`', function (done) {
emitter.delegate({
foo: 'bar',
qux: 123
})
test.strictEqual(emitter.foo, 'bar')
test.strictEqual(emitter.qux, 123)
done()
})
test('should emit `define` event on each `.define` call', function (done) {
var app = dush().use(methods())
app.on('define', function (prop, val) {
test.strictEqual(prop, 'foo')
test.strictEqual(val, 444)
done()
})
app.define('foo', 444)
})
test('should emit `delegate` on `.delegate` call', function (done) {
emitter.on('delegate', function (obj) {
test.strictEqual(obj.aaa, 'bbb')
done()
})
emitter.delegate({
aaa: 'bbb'
})
})