Skip to content

Commit

Permalink
Created tests to verify the fix to verifying connection.json accessib…
Browse files Browse the repository at this point in the history
…ility

#2003
  • Loading branch information
NTaylorMullen committed May 8, 2013
1 parent 612c960 commit 2f4a6d9
Showing 1 changed file with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

(function ($, window) {
testUtilities.runWithAllTransports(function (transport) {

QUnit.asyncTimeoutTest(transport + " transport uses custom JSON object.", testUtilities.defaultTestTimeout, function (end, assert, testName) {
var connections = [testUtilities.createConnection("signalr", end, assert, testName),
testUtilities.createHubConnection(end, assert, testName)],
numStarts = 0;

$.each(connections, function (_, connection) {
var customJsonCalled = false;

Expand All @@ -29,12 +30,48 @@
}
});
});

return function () {
$.each(connections, function (_, connection) {
connection.stop();
});
};
});

// This is not a unit test because in the case that it fails it could run async
QUnit.asyncTimeoutTest(transport + ": connection throws if no valid json parser found.", testUtilities.defaultTestTimeout, function (end, assert, testName) {
var connections = [testUtilities.createConnection("signalr", end, assert, testName),
testUtilities.createHubConnection(end, assert, testName)],
throwCount = 0,
numStarts = 0;

$.each(connections, function (_, connection) {
numStarts++;

connection.json = undefined;

try {
connection.start({ transport: transport });
}
catch (ex) {
throwCount++;
assert.ok(true, "Connection throws when no valid json is found.");
if (numStarts === connections.length) {
window.setTimeout(function () {
end();
}, 0);
}
}

assert.equal(throwCount, numStarts, "Connection threw exception on start.");
});

return function () {
$.each(connections, function (_, connection) {
connection.stop();
});
};
});

});
})($, window);

0 comments on commit 2f4a6d9

Please sign in to comment.