mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-13 08:57:59 -05:00
zuul is now archived [1] and does not support the new W3C WebDriver protocol, since it relies on the wd package [2] under the hood, which uses the (now deprecated) JSON Wire Protocol. We will now use the webdriver.io test framework, which allows to run our tests in local and on Sauce Labs (cross-browser and mobile tests). This allows us to run our tests on latest versions of Android and iOS, since Sauce Labs only supports the W3C WebDriver protocol for these platforms ([3]). [1]: https://github.com/defunctzombie/zuul [2]: https://github.com/admc/wd [3]: https://docs.saucelabs.com/dev/w3c-webdriver-capabilities/
73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
const { PacketType } = require("..");
|
|
const helpers = require("./helpers.js");
|
|
|
|
const BlobBuilderImpl =
|
|
typeof BlobBuilder !== "undefined"
|
|
? BlobBuilder
|
|
: typeof WebKitBlobBuilder !== "undefined"
|
|
? WebKitBlobBuilder
|
|
: typeof MSBlobBuilder !== "undefined"
|
|
? MSBlobBuilder
|
|
: typeof MozBlobBuilder !== "undefined"
|
|
? MozBlobBuilder
|
|
: false;
|
|
|
|
describe("Blob", () => {
|
|
it("encodes a Blob", () => {
|
|
let data;
|
|
if (BlobBuilderImpl) {
|
|
const bb = new BlobBuilderImpl();
|
|
bb.append(new ArrayBuffer(2));
|
|
data = bb.getBlob();
|
|
} else {
|
|
data = new Blob([new ArrayBuffer(2)]);
|
|
}
|
|
|
|
const packet = {
|
|
type: PacketType.EVENT,
|
|
data: ["a", data],
|
|
id: 0,
|
|
nsp: "/",
|
|
};
|
|
return helpers.test_bin(packet);
|
|
});
|
|
|
|
it("encodes an Blob deep in JSON", () => {
|
|
let data;
|
|
if (BlobBuilderImpl) {
|
|
const bb = new BlobBuilderImpl();
|
|
bb.append(new ArrayBuffer(2));
|
|
data = bb.getBlob();
|
|
} else {
|
|
data = new Blob([new ArrayBuffer(2)]);
|
|
}
|
|
|
|
const packet = {
|
|
type: PacketType.EVENT,
|
|
data: ["a", { a: "hi", b: { why: data }, c: "bye" }],
|
|
id: 999,
|
|
nsp: "/deep",
|
|
};
|
|
return helpers.test_bin(packet);
|
|
});
|
|
|
|
it("encodes a binary ack with a blob", () => {
|
|
let data;
|
|
if (BlobBuilderImpl) {
|
|
const bb = new BlobBuilderImpl();
|
|
bb.append(new ArrayBuffer(2));
|
|
data = bb.getBlob();
|
|
} else {
|
|
data = new Blob([new ArrayBuffer(2)]);
|
|
}
|
|
|
|
const packet = {
|
|
type: PacketType.ACK,
|
|
data: [{ a: "hi ack", b: { why: data }, c: "bye ack" }],
|
|
id: 999,
|
|
nsp: "/deep",
|
|
};
|
|
return helpers.test_bin(packet);
|
|
});
|
|
});
|