|
2 | 2 |
|
3 | 3 | use AneesKhan47\CloudflareImageResizing\CFImageResizing; |
4 | 4 |
|
5 | | -it('will modify the image url to have /cdn-cgi/image', function () { |
| 5 | +it('will modify the image url to have /cdn-cgi/image with default format=auto option', function () { |
6 | 6 | $url = 'https://example.com/image.jpg'; |
7 | 7 |
|
8 | 8 | $cfImage = CFImageResizing::make($url); |
9 | 9 |
|
10 | | - expect($cfImage->build())->toBe('https://example.com/cdn-cgi/image/image.jpg'); |
| 10 | + expect($cfImage->build())->toBe('https://example.com/cdn-cgi/image/format=auto/image.jpg'); |
11 | 11 | }); |
12 | 12 |
|
13 | | -it('will modify the image url to have /cdn-cgi/image if the url has a path', function () { |
| 13 | +it('will modify the image url to have /cdn-cgi/image with default format=auto option if the url has a path', function () { |
14 | 14 | $url = 'https://example.com/uploads/2023/image.jpg'; |
15 | 15 |
|
16 | 16 | $cfImage = CFImageResizing::make($url); |
17 | 17 |
|
18 | | - expect($cfImage->build())->toBe('https://example.com/cdn-cgi/image/uploads/2023/image.jpg'); |
| 18 | + expect($cfImage->build())->toBe('https://example.com/cdn-cgi/image/format=auto/uploads/2023/image.jpg'); |
19 | 19 | }); |
20 | 20 |
|
21 | 21 | it('will modify the image url to have /cdn-cgi/image with options', function () { |
|
30 | 30 | expect($cfImage)->toBe('https://example.com/cdn-cgi/image/width=300,height=300,format=jpeg/image.jpg'); |
31 | 31 | }); |
32 | 32 |
|
| 33 | +it('will not add the default format=auto option to the image url if any options is provided', function () { |
| 34 | + $url = 'https://example.com/image.jpg'; |
| 35 | + |
| 36 | + $cfImage = CFImageResizing::make($url) |
| 37 | + ->width(300) |
| 38 | + ->height(300) |
| 39 | + ->build(); |
| 40 | + |
| 41 | + expect($cfImage)->toBe('https://example.com/cdn-cgi/image/width=300,height=300/image.jpg'); |
| 42 | +}); |
| 43 | + |
33 | 44 | it('will not modify the image url if it already has /cdn-cgi/image', function () { |
34 | 45 | $url = 'https://example.com/cdn-cgi/image/image.jpg'; |
35 | 46 |
|
|
0 commit comments