Skip to content

Commit

Permalink
[patch] fix type guarding for test context assertions in @augment-vir…
Browse files Browse the repository at this point in the history
…/test
  • Loading branch information
electrovir committed Nov 11, 2024
1 parent ac6e0d9 commit eb756b4
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 48 deletions.
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/mono-repo-root",
"version": "30.6.0",
"version": "30.6.1",
"private": true,
"homepage": "https://github.com/electrovir/augment-vir",
"bugs": {
Expand Down
4 changes: 2 additions & 2 deletions packages/assert/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/assert",
"version": "30.6.0",
"version": "30.6.1",
"description": "A collection of assertions for test and production code alike.",
"keywords": [
"augment",
Expand Down Expand Up @@ -41,7 +41,7 @@
"test:update": "npm test"
},
"dependencies": {
"@augment-vir/core": "^30.6.0",
"@augment-vir/core": "^30.6.1",
"@date-vir/duration": "^6.0.1",
"deep-eql": "^5.0.2",
"expect-type": "^1.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/common",
"version": "30.6.0",
"version": "30.6.1",
"description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",
"keywords": [
"augment",
Expand Down Expand Up @@ -39,8 +39,8 @@
"test:web": "virmator --no-deps test web"
},
"dependencies": {
"@augment-vir/assert": "^30.6.0",
"@augment-vir/core": "^30.6.0",
"@augment-vir/assert": "^30.6.1",
"@augment-vir/core": "^30.6.1",
"@date-vir/duration": "^6.0.1",
"ansi-styles": "^6.2.1",
"json5": "^2.2.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/core",
"version": "30.6.0",
"version": "30.6.1",
"description": "Core augment-vir augments. Use @augment-vir/common instead.",
"homepage": "https://github.com/electrovir/augment-vir",
"bugs": {
Expand Down
8 changes: 4 additions & 4 deletions packages/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/node",
"version": "30.6.0",
"version": "30.6.1",
"description": "A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.",
"keywords": [
"augment",
Expand Down Expand Up @@ -37,16 +37,16 @@
"test:update": "npm test"
},
"dependencies": {
"@augment-vir/assert": "^30.6.0",
"@augment-vir/common": "^30.6.0",
"@augment-vir/assert": "^30.6.1",
"@augment-vir/common": "^30.6.1",
"@date-vir/duration": "^6.0.1",
"ansi-styles": "^6.2.1",
"terminate": "^2.8.0",
"type-fest": "^4.26.1",
"typed-event-target": "^4.0.2"
},
"devDependencies": {
"@augment-vir/test": "^30.6.0",
"@augment-vir/test": "^30.6.1",
"@prisma/client": "^5.22.0",
"@types/node": "^22.9.0",
"@web/dev-server-esbuild": "^1.0.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/scripts",
"version": "30.6.0",
"version": "30.6.1",
"private": true,
"homepage": "https://github.com/electrovir/augment-vir",
"bugs": {
Expand All @@ -24,14 +24,14 @@
"test:update": "npm test"
},
"dependencies": {
"@augment-vir/assert": "^30.6.0",
"@augment-vir/core": "^30.6.0",
"@augment-vir/assert": "^30.6.1",
"@augment-vir/core": "^30.6.1",
"@virmator/docs": "^13.7.0",
"jsdom": "^25.0.1",
"typedoc": "^0.26.11"
},
"devDependencies": {
"@augment-vir/test": "^30.6.0",
"@augment-vir/test": "^30.6.1",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.9.0"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/test",
"version": "30.6.0",
"version": "30.6.1",
"description": "A universal testing suite that works with Mocha style test runners _and_ Node.js's built-in test runner.",
"keywords": [
"test",
Expand Down Expand Up @@ -42,8 +42,8 @@
"test:web": "virmator test --no-deps web 'src/test-web/**/*.test.ts' 'src/augments/universal-testing-suite/**/*.test.ts'"
},
"dependencies": {
"@augment-vir/assert": "^30.6.0",
"@augment-vir/common": "^30.6.0",
"@augment-vir/assert": "^30.6.1",
"@augment-vir/common": "^30.6.1",
"@open-wc/testing-helpers": "^3.0.1",
"@virmator/test": "^13.7.0",
"type-fest": "^4.26.1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {assert} from '@augment-vir/assert';
import {RuntimeEnv} from '@augment-vir/common';
import {describe} from './universal-describe.js';
import {it} from './universal-it.js';
import {
assertTestContext,
NodeTestContext,
type UniversalTestContext,
} from './universal-test-context.js';

describe(assertTestContext.name, () => {
it('guards test context', () => {
const fakeContext: UniversalTestContext = {diagnostic: ''} as any;

assertTestContext(fakeContext, RuntimeEnv.Node);

assert.tsType(fakeContext).equals<NodeTestContext>();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ export type ContextByEnv = {
*/
export function assertWrapTestContext<const SpecificEnv extends RuntimeEnv>(
context: UniversalTestContext,
env: RuntimeEnv,
env: SpecificEnv,
): ContextByEnv[SpecificEnv] {
assertTestContext(context, env);

return context as ContextByEnv[SpecificEnv];
return context;
}

/**
Expand All @@ -68,7 +68,7 @@ export function assertWrapTestContext<const SpecificEnv extends RuntimeEnv>(
*/
export function assertTestContext<const SpecificEnv extends RuntimeEnv>(
context: UniversalTestContext,
env: RuntimeEnv,
env: SpecificEnv,
): asserts context is ContextByEnv[SpecificEnv] {
const actualEnv = determineTestContextEnv(context);

Expand Down
8 changes: 4 additions & 4 deletions packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/web",
"version": "30.6.0",
"version": "30.6.1",
"description": "A collection of augments, helpers types, functions, and classes only for web (frontend) JavaScript environments.",
"keywords": [
"augment",
Expand Down Expand Up @@ -35,14 +35,14 @@
"test:update": "npm test"
},
"dependencies": {
"@augment-vir/assert": "^30.6.0",
"@augment-vir/common": "^30.6.0",
"@augment-vir/assert": "^30.6.1",
"@augment-vir/common": "^30.6.1",
"@date-vir/duration": "^6.0.1",
"html-spec-tags": "^2.2.1",
"type-fest": "^4.26.1"
},
"devDependencies": {
"@augment-vir/test": "^30.6.0",
"@augment-vir/test": "^30.6.1",
"bowser": "^2.11.0",
"typescript": "^5.6.3"
},
Expand Down

0 comments on commit eb756b4

Please sign in to comment.