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

BIN
bun.lockb

Binary file not shown.

View file

@ -18,12 +18,18 @@
"dev": "vinxi dev",
"build": "vinxi build",
"start": "vinxi start",
"version": "vinxi version"
"version": "vinxi version",
"test": "vitest"
},
"type": "module",
"devDependencies": {
"@solidjs/testing-library": "^0.8.10",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/user-event": "^14.5.2",
"@types/wicg-file-system-access": "^2023.10.5",
"jsdom": "^25.0.1",
"vite-plugin-pwa": "^0.20.5",
"vitest": "^2.1.4",
"workbox-window": "^7.3.0"
}
}

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();
});
});

View file

@ -12,8 +12,9 @@
"noEmit": true,
"types": [
"@solidjs/start/env",
"vinxi/types/client",
"@testing-library/jest-dom",
"@types/wicg-file-system-access",
"vinxi/types/client",
"vite-plugin-pwa/solid"
],
"isolatedModules": true,

10
vitest.config.ts Normal file
View file

@ -0,0 +1,10 @@
import solid from "vite-plugin-solid"
import { defineConfig } from "vitest/config"
export default defineConfig({
plugins: [solid()],
root: './src',
resolve: {
conditions: ["development", "browser"],
},
})