Tidy testing

This commit is contained in:
James 2025-08-07 09:36:36 +01:00
parent 8c4a646fe3
commit e7f6fd5e91
2 changed files with 15 additions and 11 deletions

View File

@ -160,9 +160,9 @@ describe('SanitizeSettings', () => {
); );
// Verify that translation keys are being called (just check that it was called, not specific order) // 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.title', expect.any(String));
expect(mockT).toHaveBeenCalledWith('sanitize.options.removeJavaScript', 'Remove JavaScript'); expect(mockT).toHaveBeenCalledWith('sanitize.options.removeJavaScript', expect.any(String));
expect(mockT).toHaveBeenCalledWith('sanitize.options.removeEmbeddedFiles', 'Remove Embedded Files'); expect(mockT).toHaveBeenCalledWith('sanitize.options.removeEmbeddedFiles', expect.any(String));
expect(mockT).toHaveBeenCalledWith('sanitize.options.note', expect.any(String)); expect(mockT).toHaveBeenCalledWith('sanitize.options.note', expect.any(String));
}); });

View File

@ -32,11 +32,15 @@ vi.mock('../../../contexts/FileContext', () => ({
// Mock fetch // Mock fetch
const mockFetch = vi.fn(); const mockFetch = vi.fn();
globalThis.fetch = mockFetch; vi.stubGlobal('fetch', mockFetch);
// Mock URL.createObjectURL and revokeObjectURL // Mock URL.createObjectURL and revokeObjectURL
globalThis.URL.createObjectURL = vi.fn(() => 'mock-blob-url'); const mockCreateObjectURL = vi.fn(() => 'mock-blob-url');
globalThis.URL.revokeObjectURL = vi.fn(); const mockRevokeObjectURL = vi.fn();
vi.stubGlobal('URL', {
createObjectURL: mockCreateObjectURL,
revokeObjectURL: mockRevokeObjectURL
});
describe('useSanitizeOperation', () => { describe('useSanitizeOperation', () => {
const mockGenerateSanitizedFileName = (originalFileName?: string): string => { const mockGenerateSanitizedFileName = (originalFileName?: string): string => {