mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-03-16 22:20:23 +00:00
Added tests for ChannelDefinition.publish
This commit is contained in:
parent
fea0ddf952
commit
2cd58733d8
3 changed files with 31 additions and 18 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -13,4 +13,35 @@ describe( "ChannelDefinition", function () {
|
|||
expect( sub instanceof SubscriptionDefinition ).to.be.ok();
|
||||
} );
|
||||
} );
|
||||
describe( "When publishing from a channel definition", function(){
|
||||
var channel, subscription;
|
||||
beforeEach(function(){
|
||||
channel = postal.channel("OhHai");
|
||||
});
|
||||
afterEach(function(){
|
||||
postal.utils.reset();
|
||||
channel = undefined;
|
||||
subscription = undefined;
|
||||
});
|
||||
it( "Should allow a topic only to be used", function(){
|
||||
subscription = channel.subscribe("topic.only", function(d, e) {
|
||||
expect(typeof d === "undefined" ).to.be(true);
|
||||
});
|
||||
channel.publish("topic.only");
|
||||
});
|
||||
it( "Should allow a topic and data argument to be used", function(){
|
||||
subscription = channel.subscribe("topic.and.data", function(d, e) {
|
||||
expect(d).to.be("hai");
|
||||
});
|
||||
channel.publish("topic.and.data", "hai");
|
||||
});
|
||||
it( "Should allow an envelope argument to be used", function(){
|
||||
subscription = channel.subscribe("envelope", function(d, e) {
|
||||
expect( e.channel).to.be("OhHai");
|
||||
expect( e.data).to.be("hai");
|
||||
expect( e.foo).to.be("bar");
|
||||
});
|
||||
channel.publish({ topic: "envelope", data: "hai", foo: "bar" });
|
||||
});
|
||||
});
|
||||
} );
|
||||
Loading…
Reference in a new issue