From b1538a0fa4d9e6e98fdd06eed1a8699d11c8fdc0 Mon Sep 17 00:00:00 2001 From: samhed Date: Fri, 3 Jun 2016 14:13:35 +0200 Subject: [PATCH] Fix 'sent' assertion We were completely mishandling the length of the data. Make sure we look at the length of the websocket rather than the websock object, and also compare with the expected length. --- tests/assertions.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/assertions.js b/tests/assertions.js index 4bd0cf40..fa122dc3 100644 --- a/tests/assertions.js +++ b/tests/assertions.js @@ -37,10 +37,14 @@ chai.use(function (_chai, utils) { }; var data = obj._websocket._get_sent_data(); var same = true; - for (var i = 0; i < obj.length; i++) { - if (data[i] != target_data[i]) { - same = false; - break; + if (data.length != target_data.length) { + same = false; + } else { + for (var i = 0; i < data.length; i++) { + if (data[i] != target_data[i]) { + same = false; + break; + } } } if (!same) {