mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
* СB-6265 sets up vitest instead of jest * CB-6265 gets back core-utils tests * СB-6265 gets back react-testing-library tests * СB-6265 gets back some tests from another plugins * CB-6265 renames dist -> lib in each plugin + removes all jest from the repo * CB-6265 disables watch mode so build can go on * CB-6265 extends tests types for react-testing-library * CB-6265 reverts dist->lib rename cause it contains other assets also * CB-6265 moves setupFiles to the vitest.config.ts * CB-6265 pr fixes * CB-6265 fixes tests run for Windows * CB-6265 removes global: true in config + uses jest-dom/vitest lib to have extended expect types * CB-6565 removes unused deps * СB-6265 improves performance of the test x10 times * CB-6265 gets back renderInApp, fixes vitest setup reset config for mocks, cleans up * CB-6265 reset -> restore all mocks * CB-6265 fixes unit tests * CB-6265 vitest.setup.ts cleanup * CB-6265 timestamp to date shows military time both: on unix and windows (win tests fix) * CB-6265 improves tests running (sequential run instead of parallel) * CB-6265 cleanup * CB-6265 eslint fix * CB-6265 eslint fix 2 * CB-6265 reverts useCombined handler * CB-6265 reverts some tests * CB-6265 removes all redundant timer configs * Merge branch 'devel' into CB-6265-return-front-unit-tests-after-migration * CB-6265 pr fixes * CB-6265 fixes time for windows * CB-6265 removes default fake timers before each test
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
/*
|
|
* CloudBeaver - Cloud Database Manager
|
|
* Copyright (C) 2020-2025 DBeaver Corp and others
|
|
*
|
|
* Licensed under the Apache License, Version 2.0.
|
|
* you may not use this file except in compliance with the License.
|
|
*/
|
|
import { describe, expect, it, vitest } from 'vitest';
|
|
|
|
import { LoadingError } from './LoadingError.js';
|
|
|
|
describe('LoadingError', () => {
|
|
it('should be instance of Error', () => {
|
|
const error = new LoadingError(() => {}, 'test');
|
|
|
|
expect(error instanceof Error).toBeTruthy();
|
|
});
|
|
|
|
it('should trigger onRefresh', () => {
|
|
const onRefresh = vitest.fn();
|
|
const error = new LoadingError(onRefresh, 'test');
|
|
|
|
error.refresh();
|
|
|
|
expect(onRefresh).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('should refresh cause of the cause', () => {
|
|
const onRefresh = vitest.fn();
|
|
const cause = new LoadingError(onRefresh, 'test');
|
|
const causeCause = new LoadingError(onRefresh, 'test', { cause });
|
|
const error = new LoadingError(onRefresh, 'test', { cause: causeCause });
|
|
|
|
vitest.spyOn(causeCause, 'refresh');
|
|
vitest.spyOn(cause, 'refresh');
|
|
|
|
error.refresh();
|
|
|
|
expect(causeCause.refresh).toHaveBeenCalledTimes(1);
|
|
expect(cause.refresh).toHaveBeenCalledTimes(1);
|
|
|
|
expect(onRefresh).toHaveBeenCalledTimes(3);
|
|
expect(error.cause).toBe(causeCause);
|
|
});
|
|
|
|
it('should pass cause through the regular error', () => {
|
|
const onRefresh = vitest.fn();
|
|
const cause = new LoadingError(onRefresh, 'test', { cause: 'unit test' });
|
|
const regularError = new Error('test', { cause });
|
|
const error = new LoadingError(onRefresh, 'test', { cause: regularError });
|
|
|
|
vitest.spyOn(cause, 'refresh');
|
|
|
|
error.refresh();
|
|
|
|
expect(cause.refresh).toHaveBeenCalledTimes(1);
|
|
expect(onRefresh).toHaveBeenCalledTimes(2);
|
|
});
|
|
});
|