initial start with tests
This commit is contained in:
parent
b8e3a76768
commit
5af8fee981
5 changed files with 41 additions and 2 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
@ -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
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();
|
||||
});
|
||||
});
|
|
@ -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
10
vitest.config.ts
Normal 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"],
|
||||
},
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue