Skip to content

Commit a96d925

Browse files
committed
test: add fallback case for no usable vw tokens in getResponsiveImageAttributes
1 parent e543d8e commit a96d925

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/getResponsiveImageAttributes.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,18 @@ describe('getResponsiveImageAttributes', () => {
142142
width: 450
143143
});
144144
})
145+
146+
it("fallback when no usable vw tokens", () => {
147+
const out = getResponsiveImageAttributes({
148+
src: 'sample.jpg',
149+
urlEndpoint: 'https://ik.imagekit.io/demo',
150+
sizes: "100%"
151+
});
152+
expect(out).to.deep.equal({
153+
src: "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max",
154+
srcSet: "https://ik.imagekit.io/demo/sample.jpg?tr=w-16,c-at_max 16w, https://ik.imagekit.io/demo/sample.jpg?tr=w-32,c-at_max 32w, https://ik.imagekit.io/demo/sample.jpg?tr=w-48,c-at_max 48w, https://ik.imagekit.io/demo/sample.jpg?tr=w-64,c-at_max 64w, https://ik.imagekit.io/demo/sample.jpg?tr=w-96,c-at_max 96w, https://ik.imagekit.io/demo/sample.jpg?tr=w-128,c-at_max 128w, https://ik.imagekit.io/demo/sample.jpg?tr=w-256,c-at_max 256w, https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w",
155+
sizes: "100%"
156+
});
157+
})
158+
145159
});

0 commit comments

Comments
 (0)