Skip to content

Commit

Permalink
chore: fix tests and type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Oct 25, 2023
1 parent 1e9fd65 commit 22d1dbf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
13 changes: 6 additions & 7 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -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', '<rootDir>'],
roots: ['src'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
'^@std$': '<rootDir>/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',
{
Expand All @@ -17,5 +17,4 @@ const jestConfig: JestConfigWithTsJest = {
],
},
}

export default jestConfig
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down Expand Up @@ -37,4 +38,4 @@
"fuse.js": "^6.6.2",
"valibot": "^0.19.0"
}
}
}
18 changes: 6 additions & 12 deletions src/core/settings.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand All @@ -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", () => {
Expand All @@ -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")
});
});
4 changes: 1 addition & 3 deletions src/std/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"baseUrl": ".",
"inlineSources": true,
"resolveJsonModule": true,
"module": "ESNext",
"target": "ES6",
"allowJs": true,
Expand Down Expand Up @@ -32,6 +33,6 @@
}
},
"include": [
"src/**/*",
"src/**/*"
]
}

0 comments on commit 22d1dbf

Please sign in to comment.