diff --git a/jest.config.ts b/jest.config.ts index de342db8..5b1d06de 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,14 +1,14 @@ -import type { JestConfigWithTsJest } from 'ts-jest' +import { type JestConfigWithTsJest } from 'ts-jest' const jestConfig: JestConfigWithTsJest = { - // [...] - preset: 'ts-jest/presets/default-esm', // or other ESM presets + // preset: 'ts-jest/presets/default-esm', // or other ESM presets + preset: 'ts-jest', // or other ESM presets + moduleDirectories: ['node_modules', ''], + roots: ['src'], moduleNameMapper: { - '^(\\.{1,2}/.*)\\.js$': '$1', + '^@std$': '/src/std/$1', }, transform: { - // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` - // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` '^.+\\.tsx?$': [ 'ts-jest', { @@ -17,5 +17,4 @@ const jestConfig: JestConfigWithTsJest = { ], }, } - export default jestConfig diff --git a/package.json b/package.json index 8f872f5d..2a6717d4 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "npm run check && node esbuild.config.mjs production", "check": "svelte-check --tsconfig tsconfig.json", "test": "jest", + "test-w": "jest --watch", "version": "node version-bump.mjs && git add manifest.json versions.json" }, "keywords": [], @@ -37,4 +38,4 @@ "fuse.js": "^6.6.2", "valibot": "^0.19.0" } -} +} \ No newline at end of file diff --git a/src/core/settings.test.ts b/src/core/settings.test.ts index aa820199..93e00833 100644 --- a/src/core/settings.test.ts +++ b/src/core/settings.test.ts @@ -1,16 +1,10 @@ -import { parseSettings } from "./settings"; +import { NullSettingsError, parseSettings } from "./settings"; import * as E from "fp-ts/Either"; describe("parseSettings", () => { - it("should return the default settings when given null", () => { + it("should notify a NullSettingsError when given null", () => { const result = parseSettings(null); - expect(E.isRight(result)).toBe(true); - if (E.isRight(result)) { - expect(result.right).toEqual({ - editorPosition: "right", - formDefinitions: [], - }); - } + expect(result).toEqual(E.left(new NullSettingsError())); }); it("should return the parsed settings when given valid input", () => { @@ -19,8 +13,7 @@ describe("parseSettings", () => { formDefinitions: [], }; const result = parseSettings(input); - expect(E.isRight(result)).toBe(true); - if (E.isRight(result)) expect(result.right).toEqual(input); + expect(result).toEqual(E.of(input)); }); it("should return a validation error when given invalid input", () => { @@ -30,6 +23,7 @@ describe("parseSettings", () => { }; const result = parseSettings(input); expect(E.isLeft(result)).toBe(true); - if (E.isLeft(result)) expect(result.left).toBeDefined(); + if (E.isLeft(result)) expect(result.left).toBeDefined() + else fail("Expected a left value") }); }); diff --git a/src/std/index.ts b/src/std/index.ts index 28bf041d..c01cb50a 100644 --- a/src/std/index.ts +++ b/src/std/index.ts @@ -14,8 +14,6 @@ export const E = { tryCatchK, } -export const O = { - Option -} +export const O = {} export const parse = tryCatchK(parseV, (e: unknown) => e as ValiError) diff --git a/tsconfig.json b/tsconfig.json index 55051ebc..1db31acf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "baseUrl": ".", "inlineSources": true, + "resolveJsonModule": true, "module": "ESNext", "target": "ES6", "allowJs": true, @@ -32,6 +33,6 @@ } }, "include": [ - "src/**/*", + "src/**/*" ] } \ No newline at end of file