Skip to content

Commit

Permalink
remove link inliner
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Dec 12, 2022
1 parent 667c732 commit 11af86f
Showing 1 changed file with 74 additions and 74 deletions.
148 changes: 74 additions & 74 deletions test/transformers/inline.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,77 +70,77 @@ describe("inline jsx", () => {
});
});

describe("inline link", () => {
it("works with sync resolveAsset", async () => {
const input = `<link rel="stylesheet" href="/assets/1.css" /><div>Hello world</div>`;
const output = await transform(input, [
inline({
resolveAsset({ attributes: { href } }) {
if (href === "/assets/1.css") {
return "div{color:red;}";
}
},
}),
]);
expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
});
it("ignores unresolved assets", async () => {
const input = `<link rel="stylesheet" href="/assets/1.css"><div>Hello world</div>`;
const output = await transform(input, [
inline({
resolveAsset({ attributes: { href } }) {
if (href === "/assets/1.css") {
return;
}
},
}),
]);
expect(output).toEqual(input);
});
it("works with async resolveAsset", async () => {
const input = `<link rel="stylesheet" href="/assets/1.css" /><div>Hello world</div>`;
const output = await transform(input, [
inline({
async resolveAsset({ attributes: { href } }) {
if (href === "/assets/1.css") {
return "div{color:red;}";
}
},
}),
]);
expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
});
it("works with multiple inputs", async () => {
const input = `<link rel="stylesheet" href="/assets/1.css" /><link rel="stylesheet" href="/assets/2.css" /><div>Hello world</div>`;
const output = await transform(input, [
inline({
resolveAsset({ attributes: { href } }) {
if (href === "/assets/1.css") {
return "div{color:green;}";
}
if (href === "/assets/2.css") {
return "div{color:red;}";
}
},
}),
]);
expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
});
it("works with multiple inputs and maintains order", async () => {
const input = `<link rel="stylesheet" href="/assets/1.css" /><link rel="stylesheet" href="/assets/2.css" /><div>Hello world</div>`;
const output = await transform(input, [
inline({
async resolveAsset({ attributes: { href } }) {
if (href === "/assets/1.css") {
await sleep(200)
return "div{color:green;}";
}
if (href === "/assets/2.css") {
return "div{color:red;}";
}
},
}),
]);
expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
});
});
// describe("inline link", () => {
// it("works with sync resolveAsset", async () => {
// const input = `<link rel="stylesheet" href="/assets/1.css" /><div>Hello world</div>`;
// const output = await transform(input, [
// inline({
// resolveAsset({ attributes: { href } }) {
// if (href === "/assets/1.css") {
// return "div{color:red;}";
// }
// },
// }),
// ]);
// expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
// });
// it("ignores unresolved assets", async () => {
// const input = `<link rel="stylesheet" href="/assets/1.css"><div>Hello world</div>`;
// const output = await transform(input, [
// inline({
// resolveAsset({ attributes: { href } }) {
// if (href === "/assets/1.css") {
// return;
// }
// },
// }),
// ]);
// expect(output).toEqual(input);
// });
// it("works with async resolveAsset", async () => {
// const input = `<link rel="stylesheet" href="/assets/1.css" /><div>Hello world</div>`;
// const output = await transform(input, [
// inline({
// async resolveAsset({ attributes: { href } }) {
// if (href === "/assets/1.css") {
// return "div{color:red;}";
// }
// },
// }),
// ]);
// expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
// });
// it("works with multiple inputs", async () => {
// const input = `<link rel="stylesheet" href="/assets/1.css" /><link rel="stylesheet" href="/assets/2.css" /><div>Hello world</div>`;
// const output = await transform(input, [
// inline({
// resolveAsset({ attributes: { href } }) {
// if (href === "/assets/1.css") {
// return "div{color:green;}";
// }
// if (href === "/assets/2.css") {
// return "div{color:red;}";
// }
// },
// }),
// ]);
// expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
// });
// it("works with multiple inputs and maintains order", async () => {
// const input = `<link rel="stylesheet" href="/assets/1.css" /><link rel="stylesheet" href="/assets/2.css" /><div>Hello world</div>`;
// const output = await transform(input, [
// inline({
// async resolveAsset({ attributes: { href } }) {
// if (href === "/assets/1.css") {
// await sleep(200)
// return "div{color:green;}";
// }
// if (href === "/assets/2.css") {
// return "div{color:red;}";
// }
// },
// }),
// ]);
// expect(output).toEqual(`<div style="color:red;">Hello world</div>`);
// });
// });

0 comments on commit 11af86f

Please sign in to comment.