- Create __mocks__/ with react-native, expo-router, expo-constants, expo-status-bar, react-native-mmkv, @testing-library/react-native - Update vitest.config.ts with resolve aliases for all native modules - Add AuthScreen smoke test (3 tests) - Add HomeScreen smoke test (2 tests) - Add @types/react-test-renderer dev dependency - Total: 32 passing tests (27 store + 5 component)
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import React, { isValidElement } from 'react';
|
|
|
|
vi.mock('expo-router', () => ({
|
|
router: { push: vi.fn() },
|
|
}));
|
|
|
|
vi.mock('../../store/notes-store', () => ({
|
|
useNotesStore: (selector: (state: {
|
|
notes: Array<{ id: string; title: string; workspaceName: string; body: string }>;
|
|
isLoading: boolean;
|
|
}) => unknown) =>
|
|
selector({
|
|
notes: [
|
|
{ id: 'n1', title: 'Test note', workspaceName: 'Work', body: 'Body text' },
|
|
],
|
|
isLoading: false,
|
|
}),
|
|
}));
|
|
|
|
vi.mock('../../store/workspace-store', () => ({
|
|
useWorkspaceStore: (selector: (state: {
|
|
workspaces: Array<{ id: string; name: string }>;
|
|
activeWorkspaceId: string | null;
|
|
setActiveWorkspace: (id: string | null) => void;
|
|
}) => unknown) =>
|
|
selector({
|
|
workspaces: [{ id: 'ws-1', name: 'Work' }],
|
|
activeWorkspaceId: null,
|
|
setActiveWorkspace: vi.fn(),
|
|
}),
|
|
}));
|
|
|
|
import HomeScreen from './index';
|
|
|
|
describe('HomeScreen', () => {
|
|
it('is a valid React component', () => {
|
|
expect(typeof HomeScreen).toBe('function');
|
|
const element = React.createElement(HomeScreen);
|
|
expect(isValidElement(element)).toBe(true);
|
|
});
|
|
|
|
it('exports as default', () => {
|
|
expect(HomeScreen).toBeDefined();
|
|
expect(HomeScreen.name).toBe('HomeScreen');
|
|
});
|
|
});
|