-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathchannels.js
48 lines (42 loc) · 1.49 KB
/
channels.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
'use strict';
var should = require('chai').should(),
path = require('path'),
grasshopper,
start = require('./_start');
describe('Grasshopper core - testing channels', function(){
before(function(done) {
this.timeout(10000);
start(grasshopper).then(function(gh) { grasshopper = gh; done(); });
});
after(function(){
this.timeout(10000);
});
describe('Registering channels', function(){
it('I should be able to register a channel and fire and event and get the result.', function(done){
grasshopper.event.channel('/type/1').on('save', function(payload, next){
payload.should.equal(true);
next();
});
grasshopper
.event.emit('save', { type:'1' }, true)
.then(done.bind(null, null))
.fail(done)
.catch(done)
.done();
});
});
describe('Test validation event emitter', function(){
it('I should be able to register a channel and fire and event and get the result.', function(done){
grasshopper.event.channel('/type/1').on('validate', function(payload, next){
payload.should.equal(true);
next();
});
grasshopper
.event.emit('validate', { type:'1' }, true)
.then(done.bind(null, null))
.fail(done)
.catch(done)
.done();
});
});
});