Skip to content

Commit

Permalink
test(display): use effectScope
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Feb 3, 2025
1 parent a5efcf1 commit 1950f2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createDisplay } from '../display'

// Utilities
import { page } from '@vitest/browser/context'
import { effectScope } from 'vue'

const breakpoints = [
'xs',
Expand Down Expand Up @@ -262,7 +263,8 @@ describe('display', () => {
])('should calculate breakpoint for $description', async (options, expected) => {
await page.viewport(options.width, options.height)

const display = createDisplay()
const scope = effectScope()
const display = scope.run(() => createDisplay())!

const matched = breakpoints.reduce<(typeof breakpoints[number])[]>((acc, breakpoint) => {
if (display[breakpoint].value) acc.push(breakpoint)
Expand All @@ -273,9 +275,10 @@ describe('display', () => {
})

it('should override default thresholds', async () => {
const { name } = createDisplay({
const scope = effectScope()
const { name } = scope.run(() => createDisplay({
thresholds: { sm: 400 },
})
}))!

await page.viewport(400, 900)
await expect.poll(() => name.value).toBe('sm')
Expand All @@ -285,7 +288,8 @@ describe('display', () => {
})

it('should allow breakpoint strings for mobileBreakpoint', async () => {
const { mobile } = createDisplay({ mobileBreakpoint: 'lg' })
const scope = effectScope()
const { mobile } = scope.run(() => createDisplay({ mobileBreakpoint: 'lg' }))!

await page.viewport(1920, 900)
await expect.poll(() => mobile.value).toBe(false)
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function createVuetify (vuetify: VuetifyOptions = {}) {
date,
goTo,
}
})
})!
}

export const version = __VUETIFY_VERSION__
Expand Down

0 comments on commit 1950f2b

Please sign in to comment.