Skip to content

Commit

Permalink
format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed May 31, 2023
1 parent 7c1632f commit e578472
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions test/parser.js
@@ -1,9 +1,4 @@
const {
PacketType,
Decoder,
Encoder,
isPacketValid,
} = require("..");
const { PacketType, Decoder, Encoder, isPacketValid } = require("..");
const expect = require("expect.js");
const helpers = require("./helpers.js");

Expand Down Expand Up @@ -155,21 +150,31 @@ describe("socket.io-parser", () => {

it("should ensure that a packet is valid", () => {
expect(isPacketValid({ type: 0, nsp: "/" })).to.eql(true);
expect(isPacketValid({ type: 0, nsp: "/", data: { foo: "bar" } })).to.eql(true);
expect(isPacketValid({ type: 0, nsp: "/", data: { foo: "bar" } })).to.eql(
true
);
expect(isPacketValid({ type: 1, nsp: "/" })).to.eql(true);
expect(isPacketValid({ type: 2, nsp: "/", data: ["foo"] })).to.eql(true);
expect(isPacketValid({ type: 2, nsp: "/", data: [1] })).to.eql(true);
expect(isPacketValid({ type: 3, nsp: "/", id: 1, data: ["foo"] })).to.eql(true);
expect(isPacketValid({ type: 3, nsp: "/", id: 1, data: ["foo"] })).to.eql(
true
);
expect(isPacketValid({ type: 4, nsp: "/", data: "foo" })).to.eql(true);
expect(isPacketValid({ type: 4, nsp: "/", data: { foo: "bar" } })).to.eql(true);
expect(isPacketValid({ type: 4, nsp: "/", data: { foo: "bar" } })).to.eql(
true
);

expect(isPacketValid({ type: 9, nsp: "/" })).to.eql(false);
expect(isPacketValid({ type: 0 })).to.eql(false);
expect(isPacketValid({ type: 0, nsp: 1 })).to.eql(false);
expect(isPacketValid({ type: 0, nsp: "/", data: ["foo"] })).to.eql(false);
expect(isPacketValid({ type: 1, nsp: "/", data: ["foo"] })).to.eql(false);
expect(isPacketValid({ type: 2, nsp: "/", data: { foo: "bar" } })).to.eql(false);
expect(isPacketValid({ type: 3, nsp: "/", id: "1", data: ["foo"] })).to.eql(false);
expect(isPacketValid({ type: 2, nsp: "/", data: { foo: "bar" } })).to.eql(
false
);
expect(isPacketValid({ type: 3, nsp: "/", id: "1", data: ["foo"] })).to.eql(
false
);
expect(isPacketValid({ type: 4, nsp: "/" })).to.eql(false);
});
});

0 comments on commit e578472

Please sign in to comment.