Files
taimed/node_modules/karma-jsdom-launcher/test/native-jsdom-options-test.js
2025-07-24 17:21:45 +08:00

33 lines
911 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
let { createKarmaTest, jsdomMajorVersion } = require("./test-helper");
let { ResourceLoader } = require("jsdom");
describe("with jsdom: { … }", function () {
/*
* The configuration option tested here was only properly introduced
* in jsdom-8.0.2 and isn't available in previous versions. I wish
* there was an easier to test for this condition.
*
*/
let it = jsdomMajorVersion > 7 ? global.it : global.it.skip;
it("should pass options to jsdom", async function () {
let jsdomOptions = {};
if (jsdomMajorVersion < 12) {
jsdomOptions.userAgent = "foobar";
} else {
jsdomOptions.resources = new ResourceLoader({
userAgent: "foobar",
});
}
await createKarmaTest({ jsdom: jsdomOptions }, function () {
if (navigator.userAgent !== "foobar") {
throw new Error("Expected userAgent to equal 'foobar'");
}
});
});
});