50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import '@testing-library/jest-dom/vitest';
|
|
import { render, screen, fireEvent, cleanup, waitFor } from '@testing-library/react';
|
|
|
|
vi.mock('../../src/renderer/inbox/api.js', () => ({
|
|
inboxApi: {
|
|
getAppInfo: vi.fn(async () => ({
|
|
version: '0.2.7',
|
|
electron: '41.3.0',
|
|
node: '22.x',
|
|
os: 'darwin 23.6.0',
|
|
profileDir: '/Users/u/Library/Application Support/Inkling'
|
|
})),
|
|
openProfileDir: vi.fn(async () => undefined),
|
|
copyAppInfo: vi.fn(async () => undefined)
|
|
}
|
|
}));
|
|
|
|
import { InfoSection } from '../../src/renderer/inbox/components/settings/InfoSection';
|
|
|
|
describe('InfoSection', () => {
|
|
beforeEach(() => { vi.clearAllMocks(); cleanup(); });
|
|
|
|
it('renders version, electron, node, OS, profileDir', async () => {
|
|
render(<InfoSection />);
|
|
expect(await screen.findByText(/0\.2\.7/)).toBeInTheDocument();
|
|
expect(screen.getByText(/41\.3\.0/)).toBeInTheDocument();
|
|
expect(screen.getByText(/22\.x/)).toBeInTheDocument();
|
|
expect(screen.getByText(/darwin/)).toBeInTheDocument();
|
|
expect(screen.getByText(/Library\/Application Support\/Inkling/)).toBeInTheDocument();
|
|
});
|
|
|
|
it('"데이터 위치 열기" calls openProfileDir', async () => {
|
|
const { inboxApi } = await import('../../src/renderer/inbox/api.js');
|
|
render(<InfoSection />);
|
|
await screen.findByText(/0\.2\.7/);
|
|
fireEvent.click(screen.getByRole('button', { name: /데이터 위치 열기/ }));
|
|
await waitFor(() => expect(inboxApi.openProfileDir).toHaveBeenCalled());
|
|
});
|
|
|
|
it('"정보 복사" calls copyAppInfo', async () => {
|
|
const { inboxApi } = await import('../../src/renderer/inbox/api.js');
|
|
render(<InfoSection />);
|
|
await screen.findByText(/0\.2\.7/);
|
|
fireEvent.click(screen.getByRole('button', { name: /정보 복사/ }));
|
|
await waitFor(() => expect(inboxApi.copyAppInfo).toHaveBeenCalled());
|
|
});
|
|
});
|