Skip to content

Commit 5bfc945

Browse files
committed
test for json format parameters
1 parent 1451c60 commit 5bfc945

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

test/jimp/build/__snapshots__/test.js.snap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,36 @@ Object {
167167
}
168168
`;
169169

170+
exports[`parses json notation 1`] = `
171+
Object {
172+
"default": Object {
173+
"height": 45,
174+
"images": Array [
175+
Object {
176+
"height": 45,
177+
"path": "foobar/1eb4744a27c474d81844ec0ee8cbfaa6-50.jpg",
178+
"width": 50,
179+
},
180+
Object {
181+
"height": 90,
182+
"path": "foobar/b50e60c7d6ffdd3c4020c738c5e57270-100.jpg",
183+
"width": 100,
184+
},
185+
Object {
186+
"height": 180,
187+
"path": "foobar/4f9c9d6e52f4c3519fc4ac3e8325e69b-200.jpg",
188+
"width": 200,
189+
},
190+
],
191+
"placeholder": undefined,
192+
"src": "foobar/1eb4744a27c474d81844ec0ee8cbfaa6-50.jpg",
193+
"srcSet": "foobar/1eb4744a27c474d81844ec0ee8cbfaa6-50.jpg 50w,foobar/b50e60c7d6ffdd3c4020c738c5e57270-100.jpg 100w,foobar/4f9c9d6e52f4c3519fc4ac3e8325e69b-200.jpg 200w",
194+
"toString": [Function],
195+
"width": 50,
196+
},
197+
}
198+
`;
199+
170200
exports[`png 1`] = `
171201
Object {
172202
"default": Object {

test/jimp/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ test("multiple sizes", () => {
44
expect(multi.default.toString()).toBe(multi.default.src);
55
});
66

7+
test("parses json notation", () => {
8+
const multi = require("../cat-1000.jpg?{sizes:[50,100,200]}");
9+
expect(multi).toMatchSnapshot();
10+
});
11+
712
test("single size", () => {
813
const single = require("../cat-1000.jpg?size=500");
914
expect(single).toMatchSnapshot();

test/sharp/build/__snapshots__/test.js.snap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,36 @@ Object {
197197
}
198198
`;
199199

200+
exports[`parses json notation 1`] = `
201+
Object {
202+
"default": Object {
203+
"height": 45,
204+
"images": Array [
205+
Object {
206+
"height": 45,
207+
"path": "foobar/3980d68b1e5545406846ef85e2785741-50.webp",
208+
"width": 50,
209+
},
210+
Object {
211+
"height": 90,
212+
"path": "foobar/ed5c8d3d55565cd64634dc5ab72eab55-100.webp",
213+
"width": 100,
214+
},
215+
Object {
216+
"height": 180,
217+
"path": "foobar/40d3163ae75c85db87a1a8b8587dd12e-200.webp",
218+
"width": 200,
219+
},
220+
],
221+
"placeholder": undefined,
222+
"src": "foobar/3980d68b1e5545406846ef85e2785741-50.webp",
223+
"srcSet": "foobar/3980d68b1e5545406846ef85e2785741-50.webp 50w,foobar/ed5c8d3d55565cd64634dc5ab72eab55-100.webp 100w,foobar/40d3163ae75c85db87a1a8b8587dd12e-200.webp 200w",
224+
"toString": [Function],
225+
"width": 50,
226+
},
227+
}
228+
`;
229+
200230
exports[`png 1`] = `
201231
Object {
202232
"default": Object {

test/sharp/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ test("multiple sizes", () => {
44
expect(multi.default.toString()).toBe(multi.default.src);
55
});
66

7+
test("parses json notation", () => {
8+
const multi = require("../cat-1000.jpg?{sizes:[50,100,200], format: 'webp'}");
9+
expect(multi).toMatchSnapshot();
10+
});
11+
712
test("single size", () => {
813
const single = require("../cat-1000.jpg?size=500");
914
expect(single).toMatchSnapshot();

0 commit comments

Comments
 (0)