chore: Upgrade to Vitest 4 and regroup tests for performance (#2618)

This commit is contained in:
Dermot Duffy
2026-07-26 11:28:58 -07:00
committed by GitHub
parent a0fd464d23
commit 0c3d46ad3d
36 changed files with 1041 additions and 1207 deletions
+3 -3
View File
@@ -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();
});
});
+11 -3
View File
@@ -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(