Skip to content

Commit

Permalink
refactor: cleanly override the contents of a test directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Dec 6, 2024
1 parent b92c8b9 commit 861fb7d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
6 changes: 2 additions & 4 deletions packages/integration-tests/cypress/support/tui-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import type {
RunExCommandOutput,
RunLuaCodeOutput,
StartNeovimGenericArguments,
TestDirectory,
} from "@tui-sandbox/library/dist/src/server/types"
import type { OverrideProperties } from "type-fest"
import type { MyTestDirectory, MyTestDirectoryFile } from "../../MyTestDirectory"

export type NeovimContext = {
contents: MyTestDirectory
rootPathAbsolute: string
}
export type NeovimContext = TestDirectory<MyTestDirectory>

declare global {
interface Window {
Expand Down
6 changes: 2 additions & 4 deletions packages/library/src/server/cypress-support/contents.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ it("should return the expected contents", async () => {
RunExCommandOutput,
RunLuaCodeOutput,
StartNeovimGenericArguments,
TestDirectory,
} from "@tui-sandbox/library/dist/src/server/types"
import type { OverrideProperties } from "type-fest"
import type { MyTestDirectory, MyTestDirectoryFile } from "../../MyTestDirectory"
export type NeovimContext = {
contents: MyTestDirectory
rootPathAbsolute: string
}
export type NeovimContext = TestDirectory<MyTestDirectory>
declare global {
interface Window {
Expand Down
6 changes: 2 additions & 4 deletions packages/library/src/server/cypress-support/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ import type {
RunExCommandOutput,
RunLuaCodeOutput,
StartNeovimGenericArguments,
TestDirectory,
} from "@tui-sandbox/library/dist/src/server/types"
import type { OverrideProperties } from "type-fest"
import type { MyTestDirectory, MyTestDirectoryFile } from "../../MyTestDirectory"
export type NeovimContext = {
contents: MyTestDirectory
rootPathAbsolute: string
}
export type NeovimContext = TestDirectory<MyTestDirectory>
declare global {
interface Window {
Expand Down
4 changes: 2 additions & 2 deletions packages/library/src/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { VimValue } from "neovim/lib/types/VimValue.js"
* be written with confidence that the files and directories they expect are
* actually found. Otherwise the tests are brittle and can break easily.
*/
export type TestDirectory = {
export type TestDirectory<TContents extends object = object> = {
/** The path to the unique test directory (the root).
*
* @example /Users/mikavilpas/git/tui-sandbox/packages/integration-tests/test-environment/testdirs/dir-0199UZ
Expand All @@ -28,7 +28,7 @@ export type TestDirectory = {
*/
testEnvironmentPathRelative: string

contents: object
contents: TContents
}

export type { StartNeovimGenericArguments } from "../server/neovim/NeovimApplication.js"
Expand Down

0 comments on commit 861fb7d

Please sign in to comment.