mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-05 16:22:28 +03:00
Rename TestResult.ts to testResult.ts
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { waitFor, waitForOptions } from '@testing-library/dom';
|
||||
|
||||
const getTestResultElm = () => document.getElementById('testResult');
|
||||
|
||||
export const setTestResult = (result: boolean | null) => {
|
||||
const elm = getTestResultElm();
|
||||
if (elm) {
|
||||
if (typeof result === 'boolean') {
|
||||
if (result) {
|
||||
if (elm.getAttribute('class') === 'failed') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
elm.setAttribute('class', result ? 'passed' : 'failed');
|
||||
} else {
|
||||
elm.removeAttribute('class');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const testPassed = (): boolean => {
|
||||
const elm = getTestResultElm();
|
||||
return elm ? elm.getAttribute('class') === 'passed' : false;
|
||||
};
|
||||
|
||||
export const waitForOrFailTest = <T>(callback: () => T | Promise<T>, options?: waitForOptions) =>
|
||||
waitFor(callback, {
|
||||
...options,
|
||||
onTimeout(error: Error): Error {
|
||||
setTestResult(false);
|
||||
return error;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user