()
| 19 | 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' |
| 20 | |
| 21 | function runTests() { |
| 22 | it('should render an image tag', async () => { |
| 23 | await waitFor(1000) |
| 24 | expect(await browser.hasElementByCssSelector('img')).toBeTruthy() |
| 25 | }) |
| 26 | it('should support passing through arbitrary attributes', async () => { |
| 27 | expect( |
| 28 | await browser.hasElementByCssSelector('img#attribute-test') |
| 29 | ).toBeTruthy() |
| 30 | expect( |
| 31 | await browser.elementByCss('img#attribute-test').getAttribute('data-demo') |
| 32 | ).toBe('demo-value') |
| 33 | }) |
| 34 | it('should modify src with the loader', async () => { |
| 35 | expect(await browser.elementById('basic-image').getAttribute('src')).toBe( |
| 36 | 'https://example.com/myaccount/foo.jpg?auto=format&fit=max&w=1024&q=60' |
| 37 | ) |
| 38 | }) |
| 39 | it('should correctly generate src even if preceding slash is included in prop', async () => { |
| 40 | expect( |
| 41 | await browser.elementById('preceding-slash-image').getAttribute('src') |
| 42 | ).toBe( |
| 43 | 'https://example.com/myaccount/fooslash.jpg?auto=format&fit=max&w=1024' |
| 44 | ) |
| 45 | }) |
| 46 | it('should add a srcset based on the loader', async () => { |
| 47 | expect( |
| 48 | await browser.elementById('basic-image').getAttribute('srcset') |
| 49 | ).toBe( |
| 50 | 'https://example.com/myaccount/foo.jpg?auto=format&fit=max&w=480&q=60 1x, https://example.com/myaccount/foo.jpg?auto=format&fit=max&w=1024&q=60 2x' |
| 51 | ) |
| 52 | }) |
| 53 | it('should add a srcset even with preceding slash in prop', async () => { |
| 54 | expect( |
| 55 | await browser.elementById('preceding-slash-image').getAttribute('srcset') |
| 56 | ).toBe( |
| 57 | 'https://example.com/myaccount/fooslash.jpg?auto=format&fit=max&w=480 1x, https://example.com/myaccount/fooslash.jpg?auto=format&fit=max&w=1024 2x' |
| 58 | ) |
| 59 | }) |
| 60 | it('should use imageSizes when width matches, not deviceSizes from next.config.js', async () => { |
| 61 | expect(await browser.elementById('icon-image-16').getAttribute('src')).toBe( |
| 62 | 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=32' |
| 63 | ) |
| 64 | expect( |
| 65 | await browser.elementById('icon-image-16').getAttribute('srcset') |
| 66 | ).toBe( |
| 67 | 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=16 1x, https://example.com/myaccount/icon.png?auto=format&fit=max&w=32 2x' |
| 68 | ) |
| 69 | expect(await browser.elementById('icon-image-32').getAttribute('src')).toBe( |
| 70 | 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=64' |
| 71 | ) |
| 72 | expect( |
| 73 | await browser.elementById('icon-image-32').getAttribute('srcset') |
| 74 | ).toBe( |
| 75 | 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=32 1x, https://example.com/myaccount/icon.png?auto=format&fit=max&w=64 2x' |
| 76 | ) |
| 77 | }) |
| 78 | it('should support the unoptimized attribute', async () => { |
no test coverage detected