|
1 |
| -test("multiple sizes", () => { |
2 |
| - const multi = require("../cat-1000.jpg?sizes[]=500&sizes[]=2000"); |
3 |
| - expect(multi).toMatchSnapshot(); |
4 |
| - expect(multi.default.toString()).toBe(multi.default.src); |
5 |
| -}); |
6 |
| - |
7 |
| -test("parses json notation", () => { |
8 |
| - const multi = require("../cat-1000.jpg?{sizes:[50,100,200]}"); |
9 |
| - expect(multi).toMatchSnapshot(); |
10 |
| -}); |
11 |
| - |
12 |
| -test("single size", () => { |
13 |
| - const single = require("../cat-1000.jpg?size=500"); |
14 |
| - expect(single).toMatchSnapshot(); |
15 |
| -}); |
16 |
| - |
17 |
| -test("with size defined in webpack.config.js", () => { |
18 |
| - const multi = require("../cat-1000.jpg"); |
19 |
| - expect(multi).toMatchSnapshot(); |
20 |
| -}); |
21 |
| - |
22 |
| -test("disable", () => { |
23 |
| - const multi = require("../cat-1000.jpg?disable"); |
24 |
| - expect(multi).toMatchSnapshot(); |
25 |
| -}); |
26 |
| - |
27 |
| -test("output should be relative to context", () => { |
28 |
| - const multi = require("../cat-1000.jpg?name=[path][hash]-[width]x[height].[ext]&context=./"); |
29 |
| - expect(multi).toMatchSnapshot(); |
30 |
| -}); |
31 |
| - |
32 |
| -test("output should be in outputPath dir", () => { |
33 |
| - const multi = require("../cat-1000.jpg?outputPath=img/"); |
34 |
| - expect(multi).toMatchSnapshot(); |
35 |
| -}); |
36 |
| - |
37 |
| -test("public path should replace global publicPath", () => { |
38 |
| - const multi = require("../cat-1000.jpg?outputPath=img/&publicPath=public/"); |
39 |
| - expect(multi).toMatchSnapshot(); |
40 |
| -}); |
41 |
| - |
42 |
| -test("with placeholder image", () => { |
43 |
| - const output = require("../cat-1000.jpg?placeholder=true"); |
44 |
| - expect(output).toMatchSnapshot(); |
45 |
| -}); |
46 |
| - |
47 |
| -test("output first resized image height & width", () => { |
48 |
| - const output = require("../cat-1000.jpg?size=500"); |
49 |
| - expect(output).toMatchSnapshot(); |
50 |
| -}); |
51 |
| - |
52 |
| -test("png", () => { |
53 |
| - const output = require("../cat-transparent.png"); |
54 |
| - expect(output).toMatchSnapshot(); |
55 |
| -}); |
56 |
| - |
57 |
| -test("png to jpeg with background color", () => { |
58 |
| - const output = require("../cat-transparent.png?background=0xFF0000FF&format=jpg"); |
59 |
| - expect(output).toMatchSnapshot(); |
60 |
| -}); |
61 |
| - |
62 |
| -test("png to jpeg with background color", () => { |
63 |
| - const output = require("../cat-transparent.png?background=0xFF0000FF&format=jpg"); |
64 |
| - expect(output).toMatchSnapshot(); |
65 |
| -}); |
66 |
| - |
67 |
| -test("with min and max sizes", () => { |
68 |
| - const output = require("../cat-1000.jpg?min=600&max=800&steps=3"); |
69 |
| - expect(output).toMatchSnapshot(); |
70 |
| -}); |
71 |
| - |
72 |
| -test("with min and max sizes, and default steps", () => { |
73 |
| - const output = require("../cat-1000.jpg?min=500&max=1000"); |
74 |
| - expect(output).toMatchSnapshot(); |
75 |
| -}); |
76 |
| - |
77 |
| -test("with min and max sizes options", () => { |
78 |
| - const output = require("../cat-1000.jpg?minmax"); |
79 |
| - expect(output).toMatchSnapshot(); |
80 |
| -}); |
81 |
| - |
82 |
| -test("override min and max with sizes", () => { |
83 |
| - const output = require("../cat-1000.jpg?minmax&sizes[]=100&sizes[]=200"); |
84 |
| - expect(output).toMatchSnapshot(); |
85 |
| -}); |
86 |
| - |
87 |
| -test("override min and max with size", () => { |
88 |
| - const output = require("../cat-1000.jpg?minmax&size=100"); |
89 |
| - expect(output).toMatchSnapshot(); |
90 |
| -}); |
| 1 | +test('multiple sizes', () => { |
| 2 | + const multi = require('../cat-1000.jpg?sizes[]=500&sizes[]=2000') |
| 3 | + expect(multi).toMatchSnapshot() |
| 4 | + expect(multi.default.toString()).toBe(multi.default.src) |
| 5 | +}) |
| 6 | + |
| 7 | +test('parses json notation', () => { |
| 8 | + const multi = require('../cat-1000.jpg?{sizes:[50,100,200]}') |
| 9 | + expect(multi).toMatchSnapshot() |
| 10 | +}) |
| 11 | + |
| 12 | +test('single size', () => { |
| 13 | + const single = require('../cat-1000.jpg?size=500') |
| 14 | + expect(single).toMatchSnapshot() |
| 15 | +}) |
| 16 | + |
| 17 | +test('with size defined in webpack.config.js', () => { |
| 18 | + const multi = require('../cat-1000.jpg') |
| 19 | + expect(multi).toMatchSnapshot() |
| 20 | +}) |
| 21 | + |
| 22 | +test('disable', () => { |
| 23 | + const multi = require('../cat-1000.jpg?disable') |
| 24 | + expect(multi).toMatchSnapshot() |
| 25 | +}) |
| 26 | + |
| 27 | +test('output should be relative to context', () => { |
| 28 | + const multi = require('../cat-1000.jpg?name=[path][hash]-[width]x[height].[ext]&context=./') |
| 29 | + expect(multi).toMatchSnapshot() |
| 30 | +}) |
| 31 | + |
| 32 | +test('output should be in outputPath dir', () => { |
| 33 | + const multi = require('../cat-1000.jpg?outputPath=img/') |
| 34 | + expect(multi).toMatchSnapshot() |
| 35 | +}) |
| 36 | + |
| 37 | +test('public path should replace global publicPath', () => { |
| 38 | + const multi = require('../cat-1000.jpg?outputPath=img/&publicPath=public/') |
| 39 | + expect(multi).toMatchSnapshot() |
| 40 | +}) |
| 41 | + |
| 42 | +test('with placeholder image', () => { |
| 43 | + const output = require('../cat-1000.jpg?placeholder=true') |
| 44 | + expect(output).toMatchSnapshot() |
| 45 | +}) |
| 46 | + |
| 47 | +test('output first resized image height & width', () => { |
| 48 | + const output = require('../cat-1000.jpg?size=500') |
| 49 | + expect(output).toMatchSnapshot() |
| 50 | +}) |
| 51 | + |
| 52 | +test('png', () => { |
| 53 | + const output = require('../cat-transparent.png') |
| 54 | + expect(output).toMatchSnapshot() |
| 55 | +}) |
| 56 | + |
| 57 | +test('png to jpeg with background color', () => { |
| 58 | + const output = require('../cat-transparent.png?background=0xFF0000FF&format=jpg') |
| 59 | + expect(output).toMatchSnapshot() |
| 60 | +}) |
| 61 | + |
| 62 | +test('png to jpeg with background color', () => { |
| 63 | + const output = require('../cat-transparent.png?background=0xFF0000FF&format=jpg') |
| 64 | + expect(output).toMatchSnapshot() |
| 65 | +}) |
| 66 | + |
| 67 | +test('with min and max sizes', () => { |
| 68 | + const output = require('../cat-1000.jpg?min=600&max=800&steps=3') |
| 69 | + expect(output).toMatchSnapshot() |
| 70 | +}) |
| 71 | + |
| 72 | +test('with min and max sizes, and default steps', () => { |
| 73 | + const output = require('../cat-1000.jpg?min=500&max=1000') |
| 74 | + expect(output).toMatchSnapshot() |
| 75 | +}) |
| 76 | + |
| 77 | +test('with min and max sizes options', () => { |
| 78 | + const output = require('../cat-1000.jpg?minmax') |
| 79 | + expect(output).toMatchSnapshot() |
| 80 | +}) |
| 81 | + |
| 82 | +test('override min and max with sizes', () => { |
| 83 | + const output = require('../cat-1000.jpg?minmax&sizes[]=100&sizes[]=200') |
| 84 | + expect(output).toMatchSnapshot() |
| 85 | +}) |
| 86 | + |
| 87 | +test('override min and max with size', () => { |
| 88 | + const output = require('../cat-1000.jpg?minmax&size=100') |
| 89 | + expect(output).toMatchSnapshot() |
| 90 | +}) |
91 | 91 |
|
92 | 92 | test("doesn't emit file", () => {
|
93 |
| - const multi = require("../cat-1000.jpg?emitFile=false&sizes[]=250"); |
94 |
| - expect(multi).toMatchSnapshot(); |
95 |
| -}); |
| 93 | + const multi = require('../cat-1000.jpg?emitFile=false&sizes[]=250') |
| 94 | + expect(multi).toMatchSnapshot() |
| 95 | +}) |
0 commit comments