@@ -2,87 +2,88 @@ import { assertEquals } from "jsr:@std/assert";
2
2
import { HygraphParams , parse , transform } from "./hygraph.ts" ;
3
3
import { ParsedUrl } from "../types.ts" ;
4
4
5
- const imageBase = "https://us-west-2.graphassets.com/cm2apl1zp07l506n66dmd9xo8/cm2tr64fx7gvu07n85chjmuno" ;
5
+ const imageBase =
6
+ "https://us-west-2.graphassets.com/cm2apl1zp07l506n66dmd9xo8/cm2tr64fx7gvu07n85chjmuno" ;
6
7
7
8
const imageWithAutoFormat =
8
- "https://us-west-2.graphassets.com/cm2apl1zp07l506n66dmd9xo8/resize=fit:crop,width:400,height:400/auto_image/cm2tr64fx7gvu07n85chjmuno" ;
9
+ "https://us-west-2.graphassets.com/cm2apl1zp07l506n66dmd9xo8/resize=fit:crop,width:400,height:400/auto_image/cm2tr64fx7gvu07n85chjmuno" ;
9
10
10
- const imageWithExplicitFormat =
11
- "https://us-west-2.graphassets.com/cm2apl1zp07l506n66dmd9xo8/resize=fit:crop,width:400,height:400/output=format:jpg/cm2tr64fx7gvu07n85chjmuno" ;
11
+ const imageWithExplicitFormat =
12
+ "https://us-west-2.graphassets.com/cm2apl1zp07l506n66dmd9xo8/resize=fit:crop,width:400,height:400/output=format:jpg/cm2tr64fx7gvu07n85chjmuno" ;
12
13
13
14
Deno . test ( "hygraph" , async ( t ) => {
14
- await t . step ( "parses a URL with auto format" , ( ) => {
15
- const parsed = parse ( imageWithAutoFormat ) ;
16
- const expected : ParsedUrl < HygraphParams > = {
17
- base : imageWithAutoFormat ,
18
- cdn : "hygraph" ,
19
- format : "auto" ,
20
- width : 400 ,
21
- height : 400 ,
22
- params : {
23
- transformations : {
24
- resize : {
25
- width : 400 ,
26
- height : 400 ,
27
- fit : "crop" ,
28
- } ,
29
- auto_image : { } ,
30
- } ,
31
- region : "us-west-2" ,
32
- envId : "cm2apl1zp07l506n66dmd9xo8" ,
33
- handle : "cm2tr64fx7gvu07n85chjmuno" ,
34
- } ,
35
- } ;
15
+ await t . step ( "parses a URL with auto format" , ( ) => {
16
+ const parsed = parse ( imageWithAutoFormat ) ;
17
+ const expected : ParsedUrl < HygraphParams > = {
18
+ base : imageWithAutoFormat ,
19
+ cdn : "hygraph" ,
20
+ format : "auto" ,
21
+ width : 400 ,
22
+ height : 400 ,
23
+ params : {
24
+ transformations : {
25
+ resize : {
26
+ width : 400 ,
27
+ height : 400 ,
28
+ fit : "crop" ,
29
+ } ,
30
+ auto_image : { } ,
31
+ } ,
32
+ region : "us-west-2" ,
33
+ envId : "cm2apl1zp07l506n66dmd9xo8" ,
34
+ handle : "cm2tr64fx7gvu07n85chjmuno" ,
35
+ } ,
36
+ } ;
36
37
37
- assertEquals ( parsed , expected ) ;
38
- } ) ;
38
+ assertEquals ( parsed , expected ) ;
39
+ } ) ;
39
40
40
- await t . step ( "parses a URL with explicit format" , ( ) => {
41
- const parsed = parse ( imageWithExplicitFormat ) ;
42
- const expected : ParsedUrl < HygraphParams > = {
43
- base : imageWithExplicitFormat ,
44
- cdn : "hygraph" ,
45
- format : "jpg" ,
46
- width : 400 ,
47
- height : 400 ,
48
- params : {
49
- transformations : {
50
- resize : {
51
- width : 400 ,
52
- height : 400 ,
53
- fit : "crop" ,
54
- } ,
55
- output : {
56
- format : "jpg" ,
57
- } ,
58
- } ,
59
- region : "us-west-2" ,
60
- envId : "cm2apl1zp07l506n66dmd9xo8" ,
61
- handle : "cm2tr64fx7gvu07n85chjmuno" ,
62
- } ,
63
- } ;
41
+ await t . step ( "parses a URL with explicit format" , ( ) => {
42
+ const parsed = parse ( imageWithExplicitFormat ) ;
43
+ const expected : ParsedUrl < HygraphParams > = {
44
+ base : imageWithExplicitFormat ,
45
+ cdn : "hygraph" ,
46
+ format : "jpg" ,
47
+ width : 400 ,
48
+ height : 400 ,
49
+ params : {
50
+ transformations : {
51
+ resize : {
52
+ width : 400 ,
53
+ height : 400 ,
54
+ fit : "crop" ,
55
+ } ,
56
+ output : {
57
+ format : "jpg" ,
58
+ } ,
59
+ } ,
60
+ region : "us-west-2" ,
61
+ envId : "cm2apl1zp07l506n66dmd9xo8" ,
62
+ handle : "cm2tr64fx7gvu07n85chjmuno" ,
63
+ } ,
64
+ } ;
64
65
65
- assertEquals ( parsed , expected ) ;
66
- } ) ;
66
+ assertEquals ( parsed , expected ) ;
67
+ } ) ;
67
68
68
- await t . step ( "transforms a URL with auto format" , ( ) => {
69
- const result = transform ( {
70
- url : imageBase ,
71
- width : 400 ,
72
- height : 400 ,
73
- } ) ;
69
+ await t . step ( "transforms a URL with auto format" , ( ) => {
70
+ const result = transform ( {
71
+ url : imageBase ,
72
+ width : 400 ,
73
+ height : 400 ,
74
+ } ) ;
74
75
75
- assertEquals ( result ?. toString ( ) , imageWithAutoFormat ) ;
76
- } ) ;
76
+ assertEquals ( result ?. toString ( ) , imageWithAutoFormat ) ;
77
+ } ) ;
77
78
78
- await t . step ( "transforms a URL with explicit format" , ( ) => {
79
- const result = transform ( {
80
- url : imageBase ,
81
- width : 400 ,
82
- height : 400 ,
83
- format : "jpg" ,
84
- } ) ;
85
-
86
- assertEquals ( result ?. toString ( ) , imageWithExplicitFormat ) ;
87
- } ) ;
79
+ await t . step ( "transforms a URL with explicit format" , ( ) => {
80
+ const result = transform ( {
81
+ url : imageBase ,
82
+ width : 400 ,
83
+ height : 400 ,
84
+ format : "jpg" ,
85
+ } ) ;
86
+
87
+ assertEquals ( result ?. toString ( ) , imageWithExplicitFormat ) ;
88
+ } ) ;
88
89
} ) ;
0 commit comments