Skip to content

Commit

Permalink
test: add unit test for correct crop sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 31, 2023
1 parent a80ab4a commit 682b674
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/unit/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ describe('Renders simple image', () => {
})
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\\">"')
})

it('correctly sets crop', () => {
const img = mount(NuxtImg, {
propsData: {
src: '/image.png',
width: 1000,
height: 2000,
sizes: 'xs:100vw sm:100vw md:300px lg:350px xl:350px 2xl:350px'
}
})
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\\">"')
})
})

0 comments on commit 682b674

Please sign in to comment.