initial start with tests

This commit is contained in:
Chris Kruining 2024-11-05 16:15:09 +01:00
parent b8e3a76768
commit 5af8fee981
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
5 changed files with 41 additions and 2 deletions

22
src/utilities.spec.ts Normal file
View 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();
});
});