Skip to content

Commit 682b674

Browse files
committed
test: add unit test for correct crop sizing
1 parent a80ab4a commit 682b674

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

test/unit/image.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,16 @@ describe('Renders simple image', () => {
5454
})
5555
expect(img.html()).toMatchInlineSnapshot('"<img src=\\"/_ipx/s_900x900/%E6%B1%89%E5%AD%97.png\\" width=\\"200\\" height=\\"200\\" data-nuxt-img=\\"\\" sizes=\\"(max-width: 500px) 500px, 900px\\" srcset=\\"/_ipx/s_500x500/%E6%B1%89%E5%AD%97.png 500w, /_ipx/s_900x900/%E6%B1%89%E5%AD%97.png 900w\\">"')
5656
})
57+
58+
it('correctly sets crop', () => {
59+
const img = mount(NuxtImg, {
60+
propsData: {
61+
src: '/image.png',
62+
width: 1000,
63+
height: 2000,
64+
sizes: 'xs:100vw sm:100vw md:300px lg:350px xl:350px 2xl:350px'
65+
}
66+
})
67+
expect(img.html()).toMatchInlineSnapshot('"<img src=\\"/_ipx/s_350x700/image.png\\" width=\\"1000\\" height=\\"2000\\" data-nuxt-img=\\"\\" sizes=\\"(max-width: 320px) 100vw, (max-width: 640px) 100vw, (max-width: 768px) 300px, (max-width: 1024px) 350px, (max-width: 1280px) 350px, 350px\\" srcset=\\"/_ipx/s_320x640/image.png 320w, /_ipx/s_640x1280/image.png 640w, /_ipx/s_300x600/image.png 300w, /_ipx/s_350x700/image.png 350w, /_ipx/s_350x700/image.png 350w, /_ipx/s_350x700/image.png 350w\\">"')
68+
})
5769
})

0 commit comments

Comments
 (0)