Skip to content

Commit f86449e

Browse files
committed
Add test
1 parent f2fcfae commit f86449e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/integration/image-optimizer/test/index.test.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ function runTests({ w, isDev, domains }) {
7373
expect(isAnimated(await res.buffer())).toBe(true)
7474
})
7575

76+
it('should maintain vector svg', async () => {
77+
const query = { w, q: 90, url: '/test.svg' }
78+
const opts = { headers: { accept: 'image/webp' } }
79+
const res = await fetchViaHTTP(appPort, '/_next/image', query, opts)
80+
expect(res.status).toBe(200)
81+
expect(res.headers.get('Content-Type')).toContain('image/svg+xml')
82+
const actual = await res.text()
83+
const expected = await fs.readFile(
84+
join(__dirname, '..', 'public', 'test.svg'),
85+
'utf8'
86+
)
87+
expect(actual).toMatch(expected)
88+
})
89+
7690
it('should fail when url is missing', async () => {
7791
const query = { w, q: 100 }
7892
const res = await fetchViaHTTP(appPort, '/_next/image', query, {})
@@ -203,15 +217,6 @@ function runTests({ w, isDev, domains }) {
203217
await expectWidth(res, w)
204218
})
205219

206-
it('should resize relative url with invalid accept header as svg', async () => {
207-
const query = { url: '/test.svg', w, q: 80 }
208-
const opts = { headers: { accept: 'image/invalid' } }
209-
const res = await fetchViaHTTP(appPort, '/_next/image', query, opts)
210-
expect(res.status).toBe(200)
211-
expect(res.headers.get('Content-Type')).toBe('image/svg+xml')
212-
await expectWidth(res, w)
213-
})
214-
215220
it('should resize relative url with invalid accept header as tiff', async () => {
216221
const query = { url: '/test.tiff', w, q: 80 }
217222
const opts = { headers: { accept: 'image/invalid' } }

0 commit comments

Comments
 (0)