Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

var utf8 = require('./utf8');
var hasBinary = require('has-binary');
var after = require('after');
var keys = require('./keys');

Expand Down Expand Up @@ -217,7 +218,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) {
supportsBinary = null;
}

if (supportsBinary) {
if (supportsBinary && hasBinary(packets)) {
return exports.encodePayloadAsBinary(packets, callback);
}

Expand Down
18 changes: 0 additions & 18 deletions test/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,3 @@ if (Blob) {
}

require('./base64_object.js');

// General browser only tests
var parser = require('../../');
var encode = parser.encodePacket;
var decode = parser.decodePacket;
var encPayload = parser.encodePayload;
var decPayload = parser.decodePayload;

describe('basic functionality', function () {
it('should encode string payloads as strings even if binary supported', function (done) {
encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) {
expect(data).to.be.a('string');
done();
});
});
});


9 changes: 9 additions & 0 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ module.exports = function(parser) {
});
});

describe('basic functionality', function () {
it('should encode string payloads as strings even if binary supported', function (done) {
encPayload([{ type: 'ping' }, { type: 'post' }], true, function(data) {
expect(data).to.be.a('string');
done();
});
});
});

describe('encoding and decoding', function () {
var seen = 0;
it('should encode/decode packets', function (done) {
Expand Down