@@ -3,15 +3,15 @@ import { assertEquals } from "https://deno.land/
[email protected] /testing/asserts.ts";
3
3
import { transform } from "./kontentai.ts" ;
4
4
5
5
const img =
6
- "https://assets-us-01.kc-usercontent.com/b744f382-bfc7-434d-93e7-a65d51249bc7/cc0afdc7-23d7-4fde-be2c-f58ad54d2934/daylight.jpg"
6
+ "https://assets-us-01.kc-usercontent.com/b744f382-bfc7-434d-93e7-a65d51249bc7/cc0afdc7-23d7-4fde-be2c-f58ad54d2934/daylight.jpg" ;
7
7
8
8
Deno . test ( "kontent.ai" , async ( t ) => {
9
9
await t . step ( "should format a URL" , ( ) => {
10
10
const result = transform ( {
11
11
url : img ,
12
12
width : 200 ,
13
13
height : 100 ,
14
- format : ' webp'
14
+ format : " webp" ,
15
15
} ) ;
16
16
assertEquals (
17
17
result ?. toString ( ) ,
@@ -22,7 +22,7 @@ Deno.test("kontent.ai", async (t) => {
22
22
const result = transform ( { url : img , width : 200 } ) ;
23
23
assertEquals (
24
24
result ?. toString ( ) ,
25
- "https://assets-us-01.kc-usercontent.com/b744f382-bfc7-434d-93e7-a65d51249bc7/cc0afdc7-23d7-4fde-be2c-f58ad54d2934/daylight.jpg?w=200&fit=crop " ,
25
+ "https://assets-us-01.kc-usercontent.com/b744f382-bfc7-434d-93e7-a65d51249bc7/cc0afdc7-23d7-4fde-be2c-f58ad54d2934/daylight.jpg?w=200" ,
26
26
) ;
27
27
} ) ;
28
28
@@ -38,24 +38,27 @@ Deno.test("kontent.ai", async (t) => {
38
38
) ;
39
39
} ) ;
40
40
41
- await t . step ( "should add fit=scale when height or width (or both) provided and no other fit setting" , ( ) => {
42
- const result = transform ( {
43
- url : img ,
44
- width : 200 ,
45
- height : 100 ,
46
- } ) ;
47
- assertEquals (
48
- result ?. toString ( ) ,
49
- "https://assets-us-01.kc-usercontent.com/b744f382-bfc7-434d-93e7-a65d51249bc7/cc0afdc7-23d7-4fde-be2c-f58ad54d2934/daylight.jpg?w=200&h=100&fit=crop" ,
50
- ) ;
51
- } ) ;
41
+ await t . step (
42
+ "should add fit=scale when height or width (or both) provided and no other fit setting" ,
43
+ ( ) => {
44
+ const result = transform ( {
45
+ url : img ,
46
+ width : 200 ,
47
+ height : 100 ,
48
+ } ) ;
49
+ assertEquals (
50
+ result ?. toString ( ) ,
51
+ "https://assets-us-01.kc-usercontent.com/b744f382-bfc7-434d-93e7-a65d51249bc7/cc0afdc7-23d7-4fde-be2c-f58ad54d2934/daylight.jpg?w=200&h=100&fit=crop" ,
52
+ ) ;
53
+ } ,
54
+ ) ;
52
55
await t . step ( "should not set fit=scale if another value exists" , ( ) => {
53
56
const url = new URL ( img ) ;
54
57
url . searchParams . set ( "fit" , "scale" ) ;
55
58
const result = transform ( {
56
59
url : url ,
57
60
width : 200 ,
58
- height : 100
61
+ height : 100 ,
59
62
} ) ;
60
63
assertEquals (
61
64
result ?. toString ( ) ,
0 commit comments