Skip to content

Commit

Permalink
WIP vite test (incorrect results)
Browse files Browse the repository at this point in the history
  • Loading branch information
happycollision committed May 29, 2024
1 parent 5a7978a commit c939952
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions packages/vite/src/__tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,48 @@ describe('vite-imagetools', () => {
})
})

describe('experimental.preserveInitialOrientation', () => {
test('true affects images with orientation', async () => {
const bundle = (await build({
root: join(__dirname, '__fixtures__'),
logLevel: 'warn',
build: { write: false },
plugins: [
testEntry(`
import Image from "./exif-orientation-3.jpg?rotate=90&format=png"
window.__IMAGE__ = Image
`),
imagetools({
experimental: { preserveInitialOrientation: true }
})
]
})) as RollupOutput | RollupOutput[]

const files = getFiles(bundle, '**.png') as OutputAsset[]
expect(files[0].source).toMatchImageSnapshot()
})

test('false retains old behavior', async () => {
const bundle = (await build({
root: join(__dirname, '__fixtures__'),
logLevel: 'warn',
build: { write: false },
plugins: [
testEntry(`
import Image from "./exif-orientation-3.jpg?rotate=90&format=png"
window.__IMAGE__ = Image
`),
imagetools({
experimental: { preserveInitialOrientation: false }
})
]
})) as RollupOutput | RollupOutput[]

const files = getFiles(bundle, '**.png') as OutputAsset[]
expect(files[0].source).toMatchImageSnapshot()
})
})

describe('resolveConfigs', () => {
test('can be used to generate multiple images (presets)', async () => {
const bundle = (await build({
Expand Down

0 comments on commit c939952

Please sign in to comment.