11const  {  expect }  =  require ( 'chai' ) ; 
22const  {  getResponsiveImageAttributes }  =  require ( '../src/getResponsiveImageAttributes' ) ; 
33
4- describe . only ( 'getResponsiveImageAttributes – smoke run‑through ' ,  ( )  =>  { 
4+ describe . only ( 'getResponsiveImageAttributes' ,  ( )  =>  { 
55  it ( 'bare minimum input' ,  ( )  =>  { 
66    const  out  =  getResponsiveImageAttributes ( { 
77      src : 'sample.jpg' , 
88      urlEndpoint : 'https://ik.imagekit.io/demo' , 
99    } ) ; 
10-     // Expected object based on default deviceSizes  and imageSizes : 
10+     // Expected object based on default deviceBreakpoints  and imageBreakpoints : 
1111    expect ( out ) . to . deep . equal ( { 
1212      src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" , 
1313      srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" , 
14-       sizes : "100vw" , 
15-       width : undefined 
14+       sizes : "100vw" 
1615    } ) ; 
1716  } ) ; 
1817
@@ -26,8 +25,7 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
2625    expect ( out ) . to . deep . equal ( { 
2726      src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" , 
2827      srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" , 
29-       sizes : "100vw" , 
30-       width : undefined 
28+       sizes : "100vw" 
3129    } ) ; 
3230  } ) ; 
3331
@@ -39,9 +37,8 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
3937    } ) ; 
4038    // When width is provided without sizes attribute, the DPR strategy should be used. 
4139    expect ( out ) . to . deep . equal ( { 
42-       src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max" , 
43-       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 2x" , 
44-       sizes : undefined , 
40+       src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max" , 
41+       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 2x" , 
4542      width : 400 
4643    } ) ; 
4744  } ) ; 
@@ -50,15 +47,14 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
5047    const  out  =  getResponsiveImageAttributes ( { 
5148      src : 'sample.jpg' , 
5249      urlEndpoint : 'https://ik.imagekit.io/demo' , 
53-       deviceSizes : [ 200 ,  400 ,  800 ] , 
54-       imageSizes : [ 100 ] , 
50+       deviceBreakpoints : [ 200 ,  400 ,  800 ] , 
51+       imageBreakpoints : [ 100 ] , 
5552    } ) ; 
5653    // For custom breakpoints, the breakpoints will be derived from the provided arrays. 
5754    expect ( out ) . to . deep . equal ( { 
5855      src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-800,c-at_max" , 
5956      srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-200,c-at_max 200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-400,c-at_max 400w, https://ik.imagekit.io/demo/sample.jpg?tr=w-800,c-at_max 800w" , 
60-       sizes : "100vw" , 
61-       width : undefined 
57+       sizes : "100vw" 
6258    } ) ; 
6359  } ) ; 
6460
@@ -71,9 +67,8 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
7167    } ) ; 
7268    // The provided transformation should be preserved in the output. 
7369    expect ( out ) . to . deep . equal ( { 
74-       src : "https://ik.imagekit.io/demo/sample.jpg?tr=height-300,w-1200,c-at_max" , 
75-       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=height-300,w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=height-300,w-1200,c-at_max 2x" , 
76-       sizes : undefined , 
70+       src : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-1080,c-at_max" , 
71+       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:w-1080,c-at_max 2x" , 
7772      width : 500 
7873    } ) ; 
7974  } ) ; 
@@ -87,8 +82,8 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
8782    } ) ; 
8883    // Both sizes and width are provided, so the function should apply the sizes attribute while using width for DPR strategy. 
8984    expect ( out ) . to . deep . equal ( { 
90-       src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-1200 ,c-at_max" , 
91-       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" , 
85+       src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840 ,c-at_max" , 
86+       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w- 640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" , 
9287      sizes : "50vw" , 
9388      width : 600 
9489    } ) ; 
@@ -106,9 +101,8 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
106101    } ) ; 
107102    // Multiple caller transformations should be combined appropriately. 
108103    expect ( out ) . to . deep . equal ( { 
109-       src : "https://ik.imagekit.io/demo/sample.jpg?tr=height-300,aiRemoveBackground-true,w-828,c-at_max" , 
110-       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=height-300,aiRemoveBackground-true,w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=height-300,aiRemoveBackground-true,w-828,c-at_max 2x" , 
111-       sizes : undefined , 
104+       src : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max" , 
105+       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-640,c-at_max 1x, https://ik.imagekit.io/demo/sample.jpg?tr=h-300:e-bgremove:w-1080,c-at_max 2x" , 
112106      width : 450 
113107    } ) ; 
114108  } ) ; 
@@ -122,9 +116,8 @@ describe.only('getResponsiveImageAttributes – smoke run‑through', () => {
122116    // When specified with a sizes attribute that prunes breakpoints, the output should reflect the pruned values. 
123117    expect ( out ) . to . deep . equal ( { 
124118      src : "https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max" , 
125-       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" , 
126-       sizes : "(min-width: 800px) 33vw, 100vw" , 
127-       width : undefined 
119+       srcSet : "https://ik.imagekit.io/demo/sample.jpg?tr=w-256,c-at_max 256w, https://ik.imagekit.io/demo/sample.jpg?tr=w-384,c-at_max 384w, https://ik.imagekit.io/demo/sample.jpg?tr=w-640,c-at_max 640w, https://ik.imagekit.io/demo/sample.jpg?tr=w-750,c-at_max 750w, https://ik.imagekit.io/demo/sample.jpg?tr=w-828,c-at_max 828w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1080,c-at_max 1080w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1200,c-at_max 1200w, https://ik.imagekit.io/demo/sample.jpg?tr=w-1920,c-at_max 1920w, https://ik.imagekit.io/demo/sample.jpg?tr=w-2048,c-at_max 2048w, https://ik.imagekit.io/demo/sample.jpg?tr=w-3840,c-at_max 3840w" , 
120+       sizes : "(min-width: 800px) 33vw, 100vw" 
128121    } ) ; 
129122  } ) ; 
130123} ) ; 
0 commit comments