spec/javascript/server/handshake_spec.js in faye-0.8.8 vs spec/javascript/server/handshake_spec.js in faye-0.8.9
- old
+ new
@@ -1,29 +1,29 @@
JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() { with(this) {
before(function() { with(this) {
this.engine = {}
stub(Faye.Engine, "get").returns(engine)
this.server = new Faye.Server()
-
+
this.connectionTypes = ["long-polling", "cross-origin-long-polling",
"callback-polling","websocket",
"eventsource","in-process"]
}})
-
+
describe("#handshake", function() { with(this) {
before(function() { with(this) {
this.message = {channel: "/meta/handshake",
version: "1.0",
supportedConnectionTypes: ["long-polling"]}
}})
-
+
describe("with valid parameters", function() { with(this) {
it("creates a client", function() { with(this) {
expect(engine, "createClient")
server.handshake(message, false, function() {})
}})
-
+
it("returns a successful response", function() { with(this) {
stub(engine, "createClient").yields(["clientid"])
server.handshake(message, false, function(response) {
assertEqual({
channel: "/meta/handshake",
@@ -32,14 +32,14 @@
supportedConnectionTypes: connectionTypes,
clientId: "clientid"
}, response)
})
}})
-
+
describe("with a message id", function() { with(this) {
before(function() { this.message.id = "foo" })
-
+
it("returns the same id", function() { with(this) {
stub(engine, "createClient").yields(["clientid"])
server.handshake(message, false, function(response) {
assertEqual({
channel: "/meta/handshake",
@@ -51,19 +51,19 @@
}, response)
})
}})
}})
}})
-
+
describe("missing version", function() { with(this) {
before(function() { delete this.message.version })
-
+
it("does not create a client", function() { with(this) {
expect(engine, "createClient").exactly(0)
server.handshake(message, false, function() {})
}})
-
+
it("returns an unsuccessful response", function() { with(this) {
server.handshake(message, false, function(response) {
assertEqual({
channel: "/meta/handshake",
successful: false,
@@ -72,19 +72,19 @@
supportedConnectionTypes: connectionTypes
}, response)
})
}})
}})
-
+
describe("missing supportedConnectionTypes", function() { with(this) {
before(function() { delete this.message.supportedConnectionTypes })
-
+
it("does not create a client", function() { with(this) {
expect(engine, "createClient").exactly(0)
server.handshake(message, false, function() {})
}})
-
+
it("returns an unsuccessful response", function() { with(this) {
server.handshake(message, false, function(response) {
assertEqual({
channel: "/meta/handshake",
successful: false,
@@ -93,21 +93,21 @@
supportedConnectionTypes: connectionTypes
}, response)
})
}})
}})
-
+
describe("with no matching supportedConnectionTypes", function() { with(this) {
before(function() { with(this) {
message.supportedConnectionTypes = ["iframe", "flash"]
}})
-
+
it("does not create a client", function() { with(this) {
expect(engine, "createClient").exactly(0)
server.handshake(message, false, function() {})
}})
-
+
it("returns an unsuccessful response", function() { with(this) {
server.handshake(message, false, function(response) {
assertEqual({
channel: "/meta/handshake",
successful: false,
@@ -116,20 +116,20 @@
supportedConnectionTypes: connectionTypes
}, response)
})
}})
}})
-
+
describe("with an error", function() { with(this) {
before(function() { with(this) {
message.error = "invalid"
}})
-
+
it("does not create a client", function() { with(this) {
expect(engine, "createClient").exactly(0)
server.handshake(message, false, function() {})
}})
-
+
it("returns an unsuccessful response", function() { with(this) {
server.handshake(message, false, function(response) {
assertEqual({
channel: "/meta/handshake",
successful: false,