Commit c7071475 authored by Wandenberg's avatar Wandenberg

fix some js tests syntax

parent 43d397f7
......@@ -138,8 +138,6 @@ http {
# activate long-polling mode for this location
push_stream_subscriber long-polling;
push_stream_longpolling_connection_ttl 1s;
push_stream_message_template "{\"id\":~id~,\"channel\":\"~channel~\",\"text\":\"~text~\", \"tag\":\"~tag~\", \"time\":\"~time~\"}";
push_stream_last_received_message_time "$arg_time";
......@@ -169,7 +167,9 @@ http {
}
location / {
proxy_pass "http://localhost:8888";
if (!-f $request_filename) {
proxy_pass "http://localhost:8888";
}
}
}
}
......@@ -251,7 +251,7 @@ describe("PushStream", function() {
afterEach(function() { window.EventSource = eventsourceClass; });
it("should use only connection modes supported by the browser on the given order", function() {
var pushstream = new PushStream({modes: "stream|eventsource|longpolling"})
var pushstream = new PushStream({modes: "stream|eventsource|longpolling"});
expect(pushstream.wrappers.length).toBe(2);
expect(pushstream.wrappers[0].type).toBe("Stream");
expect(pushstream.wrappers[1].type).toBe("LongPolling");
......@@ -314,11 +314,7 @@ describe("PushStream", function() {
useJSONP: jsonp,
urlPrefixLongpolling: urlPrefixLongpolling,
onmessage: function(text, id, channel, eventid, isLastMessageFromBatch) {
expect(text).toBe("a test message");
expect(id).toBe(1);
expect(channel).toBe(channelName);
expect(eventid).toBe("");
expect(isLastMessageFromBatch).toBeTruthy();
expect([text, id, channel, eventid, isLastMessageFromBatch]).toEqual(["a test message", 1, channelName, "", true]);
receivedMessage = true;
}
});
......@@ -398,11 +394,13 @@ describe("PushStream", function() {
waitsFor(function() { return pushstream.channelsCount >= 2; }, "Channel not added", 300);
runs(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message", function() {
setTimeout(function() {
$.post("http://" + nginxServer + "/pub?id=" + "other_" + channelName, "message on other channel");
}, 700);
});
setTimeout(function() {
$.post("http://" + nginxServer + "/pub?id=" + channelName, "a test message", function() {
setTimeout(function() {
$.post("http://" + nginxServer + "/pub?id=" + "other_" + channelName, "message on other channel");
}, 700);
});
}, 700);
});
waitsFor(function() {
......@@ -471,11 +469,7 @@ describe("PushStream", function() {
return {"tests":"on"};
},
onmessage: function(text, id, channel, eventid, isLastMessageFromBatch) {
expect(text).toBe("a test message");
expect(id).toBe(1);
expect(channel).toBe("test_" + channelName);
expect(eventid).toBe("");
expect(isLastMessageFromBatch).toBeTruthy();
expect([text, id, channel, eventid, isLastMessageFromBatch]).toEqual(["a test message", 1, "test_" + channelName, "", true]);
receivedMessage = true;
}
});
......
......@@ -85,7 +85,7 @@ describe("Utils", function() {
it("should use the browser default implementation when available", function () {
spyOn(window.JSON, "parse");
Utils.parseJSON('{"a":1}')
Utils.parseJSON('{"a":1}');
expect(window.JSON.parse).toHaveBeenCalledWith('{"a":1}');
});
......@@ -102,7 +102,7 @@ describe("Utils", function() {
});
it("should raise error when string is a invalid json", function () {
expect(function () { Utils.parseJSON('{"a":1[]}') }).toThrow('Invalid JSON: {"a":1[]}');
expect(function () { Utils.parseJSON('{"a":1[]}'); }).toThrow('Invalid JSON: {"a":1[]}');
});
});
}
......@@ -131,7 +131,7 @@ describe("Utils", function() {
});
it("should raise error when string is a invalid json", function () {
expect(function () { Utils.parseJSON('{"a":1[]}') }).toThrow('Invalid JSON: {"a":1[]}');
expect(function () { Utils.parseJSON('{"a":1[]}'); }).toThrow('Invalid JSON: {"a":1[]}');
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment