Spaces:
Running
Running
File size: 953 Bytes
cdf7155 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import { describe, it, expect } from "vitest";
import {
isWebSerialSupported,
isWebUSBSupported,
} from "../../src/utils/browser-support.js";
describe("browser-support", () => {
it("should detect Web Serial API support", () => {
expect(isWebSerialSupported()).toBe(true);
});
it("should detect WebUSB API support", () => {
expect(isWebUSBSupported()).toBe(true);
});
it("should handle missing Web Serial API gracefully", () => {
const originalSerial = globalThis.navigator.serial;
delete (globalThis.navigator as any).serial;
expect(isWebSerialSupported()).toBe(false);
// Restore
globalThis.navigator.serial = originalSerial;
});
it("should handle missing WebUSB API gracefully", () => {
const originalUSB = globalThis.navigator.usb;
delete (globalThis.navigator as any).usb;
expect(isWebUSBSupported()).toBe(false);
// Restore
globalThis.navigator.usb = originalUSB;
});
});
|