-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: switch over to common JS configs and resolve issues
- Loading branch information
Showing
16 changed files
with
736 additions
and
1,507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export const calculateAnswer = async (): Promise<number> => { | ||
throw new Error(`calculateAnswer() not implemented`); | ||
}; | ||
throw new Error(`calculateAnswer() not implemented`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
export const calculateQuestion = async (answer: number): Promise<string> => { | ||
throw new Error(`calculateQuestion(${answer}) not implemented`); | ||
}; | ||
throw new Error(`calculateQuestion(${answer}) not implemented`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
import { vi, describe, afterEach, it, expect } from 'vitest'; | ||
import { when } from '../src/vitest-when.ts'; | ||
import { vi, describe, afterEach, it, expect } from 'vitest' | ||
import { when } from '../src/vitest-when.ts' | ||
|
||
import * as deepThought from './deep-thought.ts'; | ||
import * as earth from './earth.ts'; | ||
import * as subject from './meaning-of-life.ts'; | ||
import * as deepThought from './deep-thought.ts' | ||
import * as earth from './earth.ts' | ||
import * as subject from './meaning-of-life.ts' | ||
|
||
vi.mock('./deep-thought.ts'); | ||
vi.mock('./earth.ts'); | ||
vi.mock('./deep-thought.ts') | ||
vi.mock('./earth.ts') | ||
|
||
describe('get the meaning of life', () => { | ||
afterEach(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
vi.resetAllMocks() | ||
}) | ||
|
||
it('should get the answer and the question', async () => { | ||
when(deepThought.calculateAnswer).calledWith().thenResolve(42); | ||
when(earth.calculateQuestion).calledWith(42).thenResolve("What's 6 by 9?"); | ||
when(deepThought.calculateAnswer).calledWith().thenResolve(42) | ||
when(earth.calculateQuestion).calledWith(42).thenResolve("What's 6 by 9?") | ||
|
||
const result = await subject.createMeaning(); | ||
const result = await subject.createMeaning() | ||
|
||
expect(result).toEqual({ question: "What's 6 by 9?", answer: 42 }); | ||
}); | ||
}); | ||
expect(result).toEqual({ question: "What's 6 by 9?", answer: 42 }) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { calculateAnswer } from './deep-thought.ts'; | ||
import { calculateQuestion } from './earth.ts'; | ||
import { calculateAnswer } from './deep-thought.ts' | ||
import { calculateQuestion } from './earth.ts' | ||
|
||
export interface Meaning { | ||
question: string; | ||
answer: number; | ||
question: string | ||
answer: number | ||
} | ||
|
||
export const createMeaning = async (): Promise<Meaning> => { | ||
const answer = await calculateAnswer(); | ||
const question = await calculateQuestion(answer); | ||
const answer = await calculateAnswer() | ||
const question = await calculateQuestion(answer) | ||
|
||
return { question, answer }; | ||
}; | ||
return { question, answer } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,21 @@ | |
"name": "vitest-when", | ||
"version": "0.1.2", | ||
"description": "Stub behaviors of Vitest mock functions with a small, readable API.", | ||
"keywords": [ | ||
"tdd", | ||
"testing", | ||
"mocking" | ||
], | ||
"homepage": "https://github.com/mcous/vitest-when#readme", | ||
"bugs": { | ||
"url": "https://github.com/mcous/vitest-when/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mcous/vitest-when.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Michael Cousins <[email protected]> (https://mike.cousins.io)", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
|
@@ -15,75 +30,57 @@ | |
"dist", | ||
"src" | ||
], | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
}, | ||
"packageManager": "[email protected]", | ||
"author": "Michael Cousins <[email protected]> (https://mike.cousins.io)", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mcous/vitest-when.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/mcous/vitest-when/issues" | ||
}, | ||
"homepage": "https://github.com/mcous/vitest-when#readme", | ||
"keywords": [ | ||
"tdd", | ||
"testing", | ||
"mocking" | ||
], | ||
"scripts": { | ||
"_eslint": "eslint --ignore-path .lintignore \"**/*.ts\"", | ||
"_prettier": "prettier --ignore-path .lintignore \"**/*.@(ts|json|yaml|md)\"", | ||
"all": "concurrently -g pnpm:coverage pnpm:build pnpm:check:*", | ||
"build-and-check": "concurrently -g pnpm:build pnpm:check:*", | ||
"build": "tsup --clean --sourcemap --dts --format esm,cjs --target node14 src/vitest-when.ts", | ||
"test": "vitest", | ||
"coverage": "vitest run --coverage", | ||
"build-and-check": "concurrently -g pnpm:build pnpm:check:*", | ||
"check:format": "pnpm run _prettier --check", | ||
"check:lint": "pnpm run _eslint", | ||
"check:types": "vitest typecheck --run", | ||
"coverage": "vitest run --coverage", | ||
"format": "pnpm run _prettier --write && pnpm run _eslint --fix", | ||
"_eslint": "eslint --ignore-path .lintignore \"**/*.ts\"", | ||
"_prettier": "prettier --ignore-path .lintignore \"**/*.@(ts|json|yaml)\"" | ||
"test": "vitest" | ||
}, | ||
"prettier": "@mcous/prettier-config", | ||
"eslintConfig": { | ||
"extends": "@viamrobotics/eslint-config", | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": { | ||
"project": "./tsconfig.json" | ||
} | ||
} | ||
} | ||
}, | ||
"prettier": "@viamrobotics/prettier-config", | ||
"peerDependencies": { | ||
"vitest": ">=0.31.0 <1.0.0", | ||
"@vitest/expect": ">=0.31.0 <1.0.0" | ||
"extends": "@mcous/eslint-config" | ||
}, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.59.5", | ||
"@typescript-eslint/parser": "^5.59.5", | ||
"@viamrobotics/eslint-config": "^0.0.4", | ||
"@viamrobotics/prettier-config": "^0.0.1", | ||
"@viamrobotics/typescript-config": "^0.0.3", | ||
"@mcous/eslint-config": "0.3.3", | ||
"@mcous/prettier-config": "0.3.0", | ||
"@mcous/typescript-config": "0.2.1", | ||
"@typescript-eslint/eslint-plugin": "6.7.4", | ||
"@typescript-eslint/parser": "6.7.4", | ||
"@vitest/coverage-istanbul": "^0.31.0", | ||
"@vitest/expect": "^0.31.0", | ||
"concurrently": "^8.0.1", | ||
"eslint": "^8.40.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-import-resolver-typescript": "^3.5.5", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-sonarjs": "^0.19.0", | ||
"eslint-plugin-unicorn": "^46.0.1", | ||
"prettier": "^2.8.8", | ||
"eslint": "8.51.0", | ||
"eslint-config-prettier": "9.0.0", | ||
"eslint-plugin-promise": "6.1.1", | ||
"eslint-plugin-sonarjs": "0.21.0", | ||
"eslint-plugin-unicorn": "48.0.1", | ||
"prettier": "3.0.3", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.0.4", | ||
"typescript": "5.2.2", | ||
"vitest": "^0.31.0" | ||
}, | ||
"peerDependencies": { | ||
"@vitest/expect": ">=0.31.0 <1.0.0", | ||
"vitest": ">=0.31.0 <1.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@vitest/expect": { | ||
"optional": true | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha256.d713a5750e41c3660d1e090608c7f607ad00d1dd5ba9b6552b5f390bf37924e9", | ||
"publishConfig": { | ||
"access": "public", | ||
"provenance": true | ||
} | ||
} |
Oops, something went wrong.