spec/javascripts/faye-authentication_spec.js in faye-authentication-0.3.0 vs spec/javascripts/faye-authentication_spec.js in faye-authentication-0.4.0

- old
+ new

@@ -15,12 +15,12 @@ }); describe('extension', function() { beforeEach(function() { jasmine.Ajax.install(); - this.auth = new FayeAuthentication(); this.client = new Faye.Client('http://localhost:9296/faye'); + this.auth = new FayeAuthentication(this.client); this.client.addExtension(this.auth); }); afterEach(function() { jasmine.Ajax.uninstall(); @@ -116,37 +116,27 @@ expect(subscribe_message.signature).toBe('foobarsignature'); done(); }, 500); }); - it('should make only one ajax call when dealing with one channel', function(done) { - this.client.subscribe('/foobar'); - this.client.publish('/foobar', {text: 'hallo'}); - this.client.publish('/foobar', {text: 'hallo'}); - setTimeout(function() { - expect(jasmine.Ajax.requests.count()).toBe(2); // Handshake + auth - done(); - }, 500); + it('does not add the signature to a public message', function(done) { + var self = this; - }) + this.client.handshake(function() { + self.client._transport = self.fake_transport + self.client.publish('/public/foo', {text: 'hallo'}); + }, this.client); - it('should make two ajax calls when dealing with two channels', function(done) { - this.client.subscribe('/foo'); - this.client.publish('/foo', {text: 'hallo'}); - this.client.publish('/foo', {text: 'hallo'}); - - this.client.subscribe('/bar'); - this.client.publish('/bar', {text: 'hallo'}); - this.client.publish('/bar', {text: 'hallo'}); - setTimeout(function() { - expect(jasmine.Ajax.requests.count()).toBe(3); // Handshake + auth * 2 + var calls = self.fake_transport.send.calls.all(); + var last_call = calls[calls.length - 1]; + var message = last_call.args[0].message; + expect(message.channel).toBe('/public/foo'); + expect(message.signature).toBe(undefined); done(); }, 500); }); - }); + }); }); - - -}) +});