initial start with tests
This commit is contained in:
parent
b8e3a76768
commit
5af8fee981
5 changed files with 41 additions and 2 deletions
22
src/utilities.spec.ts
Normal file
22
src/utilities.spec.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { expect, describe, it, beforeEach, vi } from "vitest"
|
||||
import { debounce } from "./utilities"
|
||||
|
||||
describe('debounce', () => {
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
})
|
||||
|
||||
it('should run the given callback after the provided time', async () => {
|
||||
// Arrange
|
||||
const callback = vi.fn(() => { });
|
||||
const delay = 1000;
|
||||
const debounced = debounce(callback, delay);
|
||||
|
||||
// Act
|
||||
debounced();
|
||||
vi.runAllTimers();
|
||||
|
||||
// Assert
|
||||
expect(callback).toHaveBeenCalled();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue