chore: Upgrade to Vitest 4 and regroup tests for performance (#2618)
This commit is contained in:
@@ -32,7 +32,7 @@ import {
|
||||
setOrRemoveAttribute,
|
||||
setOrRemoveStyleProperty,
|
||||
} from '../../src/utils/basic.js';
|
||||
import { createSlot, createSlotHost } from '../test-utils.js';
|
||||
import { createSlot, createSlotHost, stubMatchMedia } from '../test-utils.js';
|
||||
|
||||
describe('prettifyTitle', () => {
|
||||
it('should return undefined when passed undefined', () => {
|
||||
@@ -146,11 +146,11 @@ describe('isHoverableDevice', () => {
|
||||
});
|
||||
|
||||
it('should return hoverable', () => {
|
||||
vi.spyOn(window, 'matchMedia').mockReturnValue(<MediaQueryList>{ matches: true });
|
||||
stubMatchMedia().mockReturnValue(<MediaQueryList>{ matches: true });
|
||||
expect(isHoverableDevice()).toBeTruthy();
|
||||
});
|
||||
it('should return not hoverable', () => {
|
||||
vi.spyOn(window, 'matchMedia').mockReturnValue(<MediaQueryList>{ matches: false });
|
||||
stubMatchMedia().mockReturnValue(<MediaQueryList>{ matches: false });
|
||||
expect(isHoverableDevice()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -71,7 +71,11 @@ describe('thumbnail utilities', () => {
|
||||
});
|
||||
vi.stubGlobal(
|
||||
'FileReader',
|
||||
vi.fn(() => mockFileReader),
|
||||
// The source calls `new FileReader()`, and a mock implementation must be
|
||||
// callable with `new`, so it cannot be an arrow function.
|
||||
vi.fn(function () {
|
||||
return mockFileReader;
|
||||
}),
|
||||
);
|
||||
|
||||
createFetchThumbnailTask(
|
||||
@@ -129,7 +133,9 @@ describe('thumbnail utilities', () => {
|
||||
const mockFileReader = mock<FileReader>();
|
||||
vi.stubGlobal(
|
||||
'FileReader',
|
||||
vi.fn(() => mockFileReader),
|
||||
vi.fn(function () {
|
||||
return mockFileReader;
|
||||
}),
|
||||
);
|
||||
|
||||
createFetchThumbnailTask(
|
||||
@@ -166,7 +172,9 @@ describe('thumbnail utilities', () => {
|
||||
});
|
||||
vi.stubGlobal(
|
||||
'FileReader',
|
||||
vi.fn(() => mockFileReader),
|
||||
vi.fn(function () {
|
||||
return mockFileReader;
|
||||
}),
|
||||
);
|
||||
|
||||
createFetchThumbnailTask(
|
||||
|
||||
Reference in New Issue
Block a user