mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-11 13:48:37 +02:00
Tidy testing
This commit is contained in:
parent
8c4a646fe3
commit
e7f6fd5e91
@ -59,7 +59,7 @@ describe('SanitizeSettings', () => {
|
||||
|
||||
const checkboxes = screen.getAllByRole('checkbox');
|
||||
const parameterValues = Object.values(defaultParameters);
|
||||
|
||||
|
||||
parameterValues.forEach((value, index) => {
|
||||
if (value) {
|
||||
expect(checkboxes[index]).toBeChecked();
|
||||
@ -80,7 +80,7 @@ describe('SanitizeSettings', () => {
|
||||
);
|
||||
|
||||
const checkboxes = screen.getAllByRole('checkbox');
|
||||
|
||||
|
||||
// Click the first checkbox (removeJavaScript - should toggle from true to false)
|
||||
fireEvent.click(checkboxes[0]);
|
||||
expect(mockOnParameterChange).toHaveBeenCalledWith('removeJavaScript', false);
|
||||
@ -160,9 +160,9 @@ describe('SanitizeSettings', () => {
|
||||
);
|
||||
|
||||
// Verify that translation keys are being called (just check that it was called, not specific order)
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.title', 'Sanitization Options');
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.removeJavaScript', 'Remove JavaScript');
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.removeEmbeddedFiles', 'Remove Embedded Files');
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.title', expect.any(String));
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.removeJavaScript', expect.any(String));
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.removeEmbeddedFiles', expect.any(String));
|
||||
expect(mockT).toHaveBeenCalledWith('sanitize.options.note', expect.any(String));
|
||||
});
|
||||
|
||||
@ -178,12 +178,12 @@ describe('SanitizeSettings', () => {
|
||||
);
|
||||
|
||||
const checkboxes = screen.getAllByRole('checkbox');
|
||||
|
||||
|
||||
// Verify checkboxes are disabled
|
||||
checkboxes.forEach(checkbox => {
|
||||
expect(checkbox).toBeDisabled();
|
||||
});
|
||||
|
||||
|
||||
// Try to click a disabled checkbox - this might still fire the event in tests
|
||||
// but we can verify the checkbox state doesn't actually change
|
||||
const firstCheckbox = checkboxes[0] as HTMLInputElement;
|
||||
@ -191,4 +191,4 @@ describe('SanitizeSettings', () => {
|
||||
fireEvent.click(firstCheckbox);
|
||||
expect(firstCheckbox.checked).toBe(initialChecked);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -32,11 +32,15 @@ vi.mock('../../../contexts/FileContext', () => ({
|
||||
|
||||
// Mock fetch
|
||||
const mockFetch = vi.fn();
|
||||
globalThis.fetch = mockFetch;
|
||||
vi.stubGlobal('fetch', mockFetch);
|
||||
|
||||
// Mock URL.createObjectURL and revokeObjectURL
|
||||
globalThis.URL.createObjectURL = vi.fn(() => 'mock-blob-url');
|
||||
globalThis.URL.revokeObjectURL = vi.fn();
|
||||
const mockCreateObjectURL = vi.fn(() => 'mock-blob-url');
|
||||
const mockRevokeObjectURL = vi.fn();
|
||||
vi.stubGlobal('URL', {
|
||||
createObjectURL: mockCreateObjectURL,
|
||||
revokeObjectURL: mockRevokeObjectURL
|
||||
});
|
||||
|
||||
describe('useSanitizeOperation', () => {
|
||||
const mockGenerateSanitizedFileName = (originalFileName?: string): string => {
|
||||
|
Loading…
Reference in New Issue
Block a user