@@ -1797,6 +1797,38 @@ describe('Image directive', () => {
17971797 expect ( img . getAttribute ( 'srcset' ) ) . toBeNull ( ) ;
17981798 } ) ;
17991799
1800+ it ( 'should add a responsive srcset to the img element if height is too large' , ( ) => {
1801+ setupTestingModule ( { imageLoader} ) ;
1802+
1803+ const template = `<img ngSrc="img" width="1100" height="2400" sizes="100vw">` ;
1804+ const fixture = createTestComponent ( template ) ;
1805+ fixture . detectChanges ( ) ;
1806+
1807+ const nativeElement = fixture . nativeElement as HTMLElement ;
1808+ const img = nativeElement . querySelector ( 'img' ) ! ;
1809+ expect ( img . getAttribute ( 'srcset' ) )
1810+ . toBe ( `${ IMG_BASE_URL } /img?w=640 640w, ${ IMG_BASE_URL } /img?w=750 750w, ${
1811+ IMG_BASE_URL } /img?w=828 828w, ${ IMG_BASE_URL } /img?w=1080 1080w, ${
1812+ IMG_BASE_URL } /img?w=1200 1200w, ${ IMG_BASE_URL } /img?w=1920 1920w, ${
1813+ IMG_BASE_URL } /img?w=2048 2048w, ${ IMG_BASE_URL } /img?w=3840 3840w`) ;
1814+ } ) ;
1815+
1816+ it ( 'should add a responsive srcset to the img element if width is too large' , ( ) => {
1817+ setupTestingModule ( { imageLoader} ) ;
1818+
1819+ const template = `<img ngSrc="img" width="3000" height="400" sizes="100vw">` ;
1820+ const fixture = createTestComponent ( template ) ;
1821+ fixture . detectChanges ( ) ;
1822+
1823+ const nativeElement = fixture . nativeElement as HTMLElement ;
1824+ const img = nativeElement . querySelector ( 'img' ) ! ;
1825+ expect ( img . getAttribute ( 'srcset' ) )
1826+ . toBe ( `${ IMG_BASE_URL } /img?w=640 640w, ${ IMG_BASE_URL } /img?w=750 750w, ${
1827+ IMG_BASE_URL } /img?w=828 828w, ${ IMG_BASE_URL } /img?w=1080 1080w, ${
1828+ IMG_BASE_URL } /img?w=1200 1200w, ${ IMG_BASE_URL } /img?w=1920 1920w, ${
1829+ IMG_BASE_URL } /img?w=2048 2048w, ${ IMG_BASE_URL } /img?w=3840 3840w`) ;
1830+ } ) ;
1831+
18001832 it ( 'should use a custom breakpoint set if one is provided' , ( ) => {
18011833 const imageConfig = {
18021834 breakpoints : [ 16 , 32 , 48 , 64 , 96 , 128 , 256 , 384 , 640 , 1280 , 3840 ] ,
0 commit comments