Skip to content

Commit 412b6b4

Browse files
committed
Continue to fix broken tests
1 parent 7ea67db commit 412b6b4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/modules-lib/src/utilities.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @title Utilities
55
*/
66

7+
import type { DebuggerContext } from './types';
8+
79
/**
810
* Converts an angle in degrees into radians
911
* @param degrees Angle in degrees
@@ -35,3 +37,21 @@ export function hexToColor(hex: string, func_name?: string): [number, number, nu
3537
parseInt(groups[3], 16) / 0xff
3638
];
3739
}
40+
41+
/**
42+
* Returns a partial {@link DebuggerContext} object that contains a context which contains the mocked
43+
* module state for the given module.
44+
* Function intended for testing use only.
45+
*/
46+
export function mockDebuggerContext<T>(moduleState: T, name: string) {
47+
return {
48+
context: {
49+
moduleContexts: {
50+
[name]: {
51+
state: moduleState,
52+
tabs: []
53+
}
54+
}
55+
}
56+
} as unknown as DebuggerContext;
57+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"test:devserver": "vitest --project \"Dev Server\"",
3939
"test:libs": "yarn workspaces foreach -ptW --from \"./lib/*\" run test",
4040
"test:modules": "yarn workspaces foreach -ptW --from \"./src/{bundles,tabs}/*\" run test",
41-
"tsc:all": "yarn workspaces foreach -pt --all run tsc",
41+
"tsc:all": "yarn workspaces foreach -pt --all --exclude \"@sourceacademy/modules\" run tsc",
4242
"tsc:devserver": "tsc --project ./devserver/tsconfig.json",
4343
"tsc:modules": "yarn workspaces foreach -ptW --from \"./src/{bundles,tabs}/*\" run tsc"
4444
},

0 commit comments

Comments
 (0)