Skip to content

Commit 50d2931

Browse files
committed
chore(lint): include test and script sources
1 parent a4e2cc5 commit 50d2931

3 files changed

Lines changed: 28 additions & 18 deletions

File tree

src/eslint.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ export default [
1212
'*.config.js',
1313
'*.config.ts',
1414
'vite.config.ts',
15-
'test/**',
16-
'**/test/**',
1715
'**/bindings.ts',
18-
'scripts/**',
19-
'**/scripts/**',
2016
],
2117
},
2218
{
@@ -107,7 +103,7 @@ export default [
107103
},
108104
},
109105
{
110-
files: ['scripts/**/*.js'],
106+
files: ['scripts/**/*.{js,mjs}'],
111107
languageOptions: {
112108
globals: {
113109
...globals.node,

src/test/integration/CatalogService.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
8-
import { CatalogService } from '@/shared/services/CatalogService';
8+
import type { CatalogService } from '@/shared/services/CatalogService';
99
import type { IModule } from '@/shared/types/coreTypes';
1010
import {
1111
createCatalogHarness,

src/test/setup.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { beforeEach, vi } from 'vitest';
22

3+
type TauriInternalsMock = {
4+
invoke: (cmd?: string, args?: unknown) => Promise<unknown>;
5+
transformCallback: () => number;
6+
eventListen: (event?: string, callback?: (payload: unknown) => void) => Promise<() => void>;
7+
};
8+
39
// Mock localStorage for JSDOM
410
const localStorageMock = (() => {
511
let store: Record<string, string> = {};
@@ -25,35 +31,43 @@ Object.defineProperty(globalThis, 'localStorage', { value: localStorageMock });
2531

2632
function installDefaultTauriGlobals(): void {
2733
const win = globalThis as unknown as Record<string, unknown>;
28-
win['__TAURI_INTERNALS__'] = {
29-
invoke: async () => {},
34+
const internals: TauriInternalsMock = {
35+
invoke: () => Promise.resolve(),
3036
transformCallback: () => 0,
31-
eventListen: async () => () => {},
37+
eventListen: () => Promise.resolve(() => {}),
3238
};
39+
win['__TAURI_INTERNALS__'] = internals;
3340
win['t'] = vi.fn((key: string, fallback?: string) => fallback ?? key);
3441
}
3542

43+
function getTauriInternals(): Partial<TauriInternalsMock> | null {
44+
const win = globalThis as unknown as Record<string, unknown>;
45+
const internals = win['__TAURI_INTERNALS__'];
46+
if (internals === null || typeof internals !== 'object') {
47+
return null;
48+
}
49+
return internals as Partial<TauriInternalsMock>;
50+
}
51+
3652
// Mock Tauri APIs
3753
vi.mock('@tauri-apps/api/core', () => ({
3854
invoke: vi.fn().mockImplementation((cmd: string, args?: unknown) => {
39-
const win = globalThis as unknown as Record<string, unknown>;
40-
const internals = win['__TAURI_INTERNALS__'] as Record<string, any> | undefined;
55+
const internals = getTauriInternals();
4156

42-
if (typeof internals?.['invoke'] === 'function') {
43-
return internals['invoke'](cmd, args);
57+
if (typeof internals?.invoke === 'function') {
58+
return internals.invoke(cmd, args);
4459
}
4560
return Promise.resolve();
4661
}),
4762
convertFileSrc: vi.fn((filePath: string) => `asset://localhost/${filePath}`),
4863
}));
4964

5065
vi.mock('@tauri-apps/api/event', () => ({
51-
listen: vi.fn().mockImplementation((event: string, callback: (payload: any) => void) => {
52-
const win = globalThis as unknown as Record<string, unknown>;
53-
const internals = win['__TAURI_INTERNALS__'] as Record<string, any> | undefined;
66+
listen: vi.fn().mockImplementation((event: string, callback: (payload: unknown) => void) => {
67+
const internals = getTauriInternals();
5468

55-
if (typeof internals?.['eventListen'] === 'function') {
56-
return internals['eventListen'](event, callback);
69+
if (typeof internals?.eventListen === 'function') {
70+
return internals.eventListen(event, callback);
5771
}
5872
return Promise.resolve(() => {});
5973
}),

0 commit comments

Comments
 (0)