@@ -26,7 +26,6 @@ import {
|
||||
runWhenIdleIfSupported,
|
||||
setify,
|
||||
setOrRemoveAttribute,
|
||||
sleep,
|
||||
} from '../../src/utils/basic.js';
|
||||
import { createSlot, createSlotHost } from '../test-utils.js';
|
||||
|
||||
@@ -185,6 +184,10 @@ describe('getDurationString', () => {
|
||||
const end = new Date(2023, 3, 14, 13, 35, 12);
|
||||
expect(getDurationString(start, end)).toBe('2s');
|
||||
});
|
||||
it('should return 0s for no delta', () => {
|
||||
const start = new Date(2023, 3, 14, 13, 35, 10);
|
||||
expect(getDurationString(start, start)).toBe('0s');
|
||||
});
|
||||
});
|
||||
|
||||
describe('allPromises', () => {
|
||||
@@ -209,19 +212,6 @@ describe('isSuperset', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('sleep', () => {
|
||||
it('should sleep', async () => {
|
||||
const spy = vi
|
||||
.spyOn(global, 'setTimeout')
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
||||
.mockImplementation((func: () => unknown, _time?: number): any => {
|
||||
func();
|
||||
});
|
||||
sleep(10);
|
||||
expect(spy).toHaveBeenCalledWith(expect.anything(), 10000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValidDate', () => {
|
||||
it('should be valid date', () => {
|
||||
expect(isValidDate(new Date(2023, 3, 28))).toBeTruthy();
|
||||
|
||||
Reference in New Issue
Block a user