2021-01-03 19:57:02 -08:00
|
|
|
const { renderOutfitImage } = require("./outfit-images");
|
|
|
|
|
|
|
|
const { toMatchImageSnapshot } = require("jest-image-snapshot");
|
|
|
|
expect.extend({ toMatchImageSnapshot });
|
|
|
|
|
2021-01-03 21:58:19 -08:00
|
|
|
const originalConsoleWarn = console.warn;
|
|
|
|
|
2021-01-03 19:57:02 -08:00
|
|
|
describe("renderOutfitImage", () => {
|
2021-01-03 21:58:19 -08:00
|
|
|
beforeEach(() => {
|
|
|
|
console.warn = jest.fn();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
console.warn = originalConsoleWarn;
|
|
|
|
});
|
|
|
|
|
|
|
|
it("renders the Moon and Stars Background and Green Leaf String Lights, as PNG", async () => {
|
|
|
|
const image = await renderOutfitImage(
|
|
|
|
[
|
|
|
|
"https://impress-asset-images.s3.amazonaws.com/object/000/000/006/6829/600x600.png",
|
|
|
|
"https://impress-asset-images.s3.amazonaws.com/object/000/000/036/36414/600x600.png",
|
|
|
|
],
|
|
|
|
600
|
|
|
|
);
|
|
|
|
expect(image).toMatchImageSnapshot();
|
|
|
|
expect(console.warn).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("renders the Moon and Stars Background and Green Leaf String Lights, as SVG", async () => {
|
|
|
|
const image = await renderOutfitImage(
|
|
|
|
[
|
|
|
|
"http://images.neopets.com/cp/items/data/000/000/006/6829_1707e50385/6829.svg",
|
|
|
|
"http://images.neopets.com/cp/items/data/000/000/036/36414_1e2aaab4ad/36414.svg",
|
|
|
|
],
|
|
|
|
600
|
|
|
|
);
|
|
|
|
expect(image).toMatchImageSnapshot();
|
|
|
|
expect(console.warn).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("skips network failures, and logs an error", async () => {
|
|
|
|
const image = await renderOutfitImage(
|
|
|
|
[
|
|
|
|
"https://impress-asset-images.s3.amazonaws.com/object/000/000/006/6829/600x600.png",
|
|
|
|
"https://impress-asset-images.s3.amazonaws.com/object/000/000/000/00000000/600x600.png", // fake URL
|
|
|
|
],
|
|
|
|
600
|
|
|
|
);
|
2021-01-03 19:57:02 -08:00
|
|
|
expect(image).toMatchImageSnapshot();
|
2021-01-03 21:58:19 -08:00
|
|
|
expect(console.warn).toHaveBeenCalledWith(
|
|
|
|
`Error loading layer, skipping: Server responded with 403. (https://impress-asset-images.s3.amazonaws.com/object/000/000/000/00000000/600x600.png)`
|
|
|
|
);
|
2021-01-03 19:57:02 -08:00
|
|
|
});
|
|
|
|
});
|