diff --git a/tests/test.websock.js b/tests/test.websock.js index 53145b360..ab09f4508 100644 --- a/tests/test.websock.js +++ b/tests/test.websock.js @@ -261,20 +261,15 @@ describe('Websock', function () { }); it('should implicitly split a large buffer', function () { let str = ''; - for (let i = 0;i <= bufferSize/5;i++) { - str += '\x12\x34\x56\x78\x90'; + let expected = []; + for (let i = 0;i < bufferSize * 3;i++) { + let byte = Math.random() * 0xff; + str += String.fromCharCode(byte); + expected.push(byte); } sock.sQpushString(str); - - let expected = []; - for (let i = 0;i < bufferSize/5;i++) { - expected.push(0x12); - expected.push(0x34); - expected.push(0x56); - expected.push(0x78); - expected.push(0x90); - } + sock.flush(); expect(sock).to.have.sent(new Uint8Array(expected)); }); @@ -308,24 +303,15 @@ describe('Websock', function () { }); it('should implicitly split a large buffer', function () { let buffer = []; - for (let i = 0;i <= bufferSize/5;i++) { - buffer.push(0x12); - buffer.push(0x34); - buffer.push(0x56); - buffer.push(0x78); - buffer.push(0x90); + let expected = []; + for (let i = 0;i < bufferSize * 3;i++) { + let byte = Math.random() * 0xff; + buffer.push(byte); + expected.push(byte); } sock.sQpushBytes(new Uint8Array(buffer)); - - let expected = []; - for (let i = 0;i < bufferSize/5;i++) { - expected.push(0x12); - expected.push(0x34); - expected.push(0x56); - expected.push(0x78); - expected.push(0x90); - } + sock.flush(); expect(sock).to.have.sent(new Uint8Array(expected)); });