-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix payload encoding for v3 clients
The v3 parser (used for compatibility with older clients) was broken during the migration to TypeScript ([1]). This was not caught in the test suite because the Node.js client does not support binary packet in polling mode (packets are base64-encoded). [1]: c0d6eaa Backported from 6.0.x branch: 3f42262
- Loading branch information
1 parent
271e2df
commit ed50fc3
Showing
2 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const expect = require("expect.js"); | ||
const parser = require("../build/parser-v3/index.js"); | ||
|
||
describe("parser", () => { | ||
it("properly encodes a mixed payload", done => { | ||
parser.encodePayload( | ||
[ | ||
{ type: "message", data: "€€€€" }, | ||
{ type: "message", data: Buffer.from([1, 2, 3]) } | ||
], | ||
true, | ||
encoded => { | ||
expect(encoded).to.be.a(Buffer); | ||
|
||
parser.decodePayload(encoded, decoded => { | ||
expect(decoded.data).to.eql("€€€€"); | ||
done(); | ||
}); | ||
} | ||
); | ||
}); | ||
}); |