Permalink
Browse files

Exercise tests with custom attachServer routes.

This validates functionality related to bug #52.
  • Loading branch information...
reid committed Apr 2, 2012
1 parent e9ead63 commit 8208ca81b22c749b739e0b26fe27bb717b25ed68
Showing with 19 additions and 9 deletions.
  1. +2 −2 test/fixture/attach-server.html
  2. +17 −7 test/functional.js
@@ -1,8 +1,8 @@
<!doctype html>
<title>Yeti Attach Server Test</title>
-<script src="/yeti-test-route/socket.io/socket.io.js"></script>
-<script src="/yeti-test-route/public/inject.js"></script>
+<script src="{route}/socket.io/socket.io.js"></script>
+<script src="{route}/public/inject.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.4.1/build/yui-base/yui-base-min.js&3.4.1/build/oop/oop-min.js&3.4.1/build/event-custom-base/event-custom-base-min.js&3.4.1/build/event-base/event-base-min.js&3.4.1/build/event-simulate/event-simulate-min.js&3.4.1/build/event-custom-complex/event-custom-complex-min.js&3.4.1/build/substitute/substitute-min.js&3.4.1/build/json-stringify/json-stringify-min.js&3.4.1/build/test/test-min.js"></script>
View
@@ -170,9 +170,19 @@ function visitorContext(createBatchConfiguration) {
var DUMMY_PROTOCOL = "YetiDummyProtocol/1.0";
-var SERVER_TEST_FIXTURE = fs.readFileSync(__dirname + "/fixture/attach-server.html");
+var SERVER_TEST_FIXTURE = fs.readFileSync(__dirname + "/fixture/attach-server.html", "utf8");
+
+function attachServerContext(testContext, explicitRoute) {
+ var route, testFixture;
+
+ if (explicitRoute) {
+ route = explicitRoute;
+ } else {
+ route = "/yeti";
+ }
+
+ testFixture = SERVER_TEST_FIXTURE.replace(/{route}/g, route);
-function attachServerContext(testContext) {
return {
topic: function () {
var vow = this,
@@ -181,7 +191,7 @@ function attachServerContext(testContext) {
res.writeHead(200, {
"Content-Type": "text/html"
});
- res.end(SERVER_TEST_FIXTURE);
+ res.end(testFixture);
} else {
res.writeHead(404, {
"Content-Type": "text/plain"
@@ -213,7 +223,7 @@ function attachServerContext(testContext) {
topic: function (server) {
var vow = this,
hub = new Hub();
- hub.attachServer(server, "/yeti-test-route");
+ hub.attachServer(server, route);
return hub;
},
"is ok": function (hub) {
@@ -249,7 +259,7 @@ function attachServerContext(testContext) {
},
"used by the Hub Client": {
// TODO: Handle without trailing slash.
- topic: hub.clientTopic("/yeti-test-route/"),
+ topic: hub.clientTopic(route + "/"),
"a browser for testing": {
topic: hub.phantomTopic(),
"visits Yeti": testContext
@@ -270,10 +280,10 @@ vows.describe("Yeti Functional")
"A HTTP server with an upgrade listener (for Yeti files)": attachServerContext(visitorContext({
basedir: __dirname + "/fixture",
tests: ["basic.html", "local-js.html"]
- })),
+ }), "/foo-test-route-1"),
"A HTTP server with an upgrade listener (for Yeti paths)": attachServerContext(visitorContext({
tests: ["/fixture"],
useProxy: false
- }))
+ }), "/bar-test-route-2")
})
.export(module);

0 comments on commit 8208ca8

Please sign in to comment.