mirror of https://github.com/webpack/webpack.git
test: make prefetch/preload tests stricter
This commit is contained in:
parent
47906948a8
commit
e79e2417c7
|
|
@ -26,7 +26,7 @@ it("should prefetch and preload child chunks on chunk load", () => {
|
|||
link = document.head._children[0];
|
||||
expect(link._type).toBe("link");
|
||||
expect(link.rel).toBe("prefetch");
|
||||
expect(link.href).toMatch(/chunk1\.js$/);
|
||||
expect(link.href).toBe("https://example.com/public/path/chunk1.js");
|
||||
|
||||
const promise = import(/* webpackChunkName: "chunk1", webpackPrefetch: true */ "./chunk1");
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ it("should prefetch and preload child chunks on chunk load", () => {
|
|||
// Test normal script loading
|
||||
script = document.head._children[1];
|
||||
expect(script._type).toBe("script");
|
||||
expect(script.src).toMatch(/chunk1\.js$/);
|
||||
expect(script.src).toBe("https://example.com/public/path/chunk1.js");
|
||||
expect(script.getAttribute("nonce")).toBe("nonce")
|
||||
expect(script.crossOrigin).toBe("anonymous");
|
||||
expect(script.onload).toBeTypeOf("function");
|
||||
|
|
@ -45,7 +45,7 @@ it("should prefetch and preload child chunks on chunk load", () => {
|
|||
expect(link._type).toBe("link");
|
||||
expect(link.rel).toBe("preload");
|
||||
expect(link.as).toBe("script");
|
||||
expect(link.href).toMatch(/chunk1-b\.js$/);
|
||||
expect(link.href).toBe("https://example.com/public/path/chunk1-b.js");
|
||||
expect(link.charset).toBe("utf-8");
|
||||
expect(link.getAttribute("nonce")).toBe("nonce");
|
||||
expect(link.crossOrigin).toBe("anonymous");
|
||||
|
|
@ -62,13 +62,13 @@ it("should prefetch and preload child chunks on chunk load", () => {
|
|||
link = document.head._children[3];
|
||||
expect(link._type).toBe("link");
|
||||
expect(link.rel).toBe("prefetch");
|
||||
expect(link.href).toMatch(/chunk1-c\.js$/);
|
||||
expect(link.href).toBe("https://example.com/public/path/chunk1-c.js");
|
||||
expect(link.crossOrigin).toBe("anonymous");
|
||||
|
||||
link = document.head._children[4];
|
||||
expect(link._type).toBe("link");
|
||||
expect(link.rel).toBe("prefetch");
|
||||
expect(link.href).toMatch(/chunk1-a\.js$/);
|
||||
expect(link.href).toBe("https://example.com/public/path/chunk1-a.js");
|
||||
expect(link.crossOrigin).toBe("anonymous");
|
||||
|
||||
const promise2 = import(/* webpackChunkName: "chunk1", webpackPrefetch: true */ "./chunk1");
|
||||
|
|
@ -83,7 +83,7 @@ it("should prefetch and preload child chunks on chunk load", () => {
|
|||
// Test normal script loading
|
||||
script = document.head._children[5];
|
||||
expect(script._type).toBe("script");
|
||||
expect(script.src).toMatch(/chunk2\.js$/);
|
||||
expect(script.src).toBe("https://example.com/public/path/chunk2.js");
|
||||
expect(script.getAttribute("nonce")).toBe("nonce")
|
||||
expect(script.crossOrigin).toBe("anonymous");
|
||||
expect(script.onload).toBeTypeOf("function");
|
||||
|
|
|
|||
Loading…
Reference in New Issue