forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix test configuration and add basic tests
- Loading branch information
1 parent
6ef15cf
commit d8080d7
Showing
5 changed files
with
84 additions
and
6 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,5 +1,8 @@ | ||
import { defineConfig } from "@vscode/test-cli" | ||
|
||
export default defineConfig({ | ||
files: "out/test/**/*.test.js", | ||
files: "out/**/*.test.js", | ||
mocha: { | ||
timeout: 20000, // Maximum time (in ms) that a test can run before failing | ||
}, | ||
}) |
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
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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as assert from "assert" | ||
import * as path from "path" | ||
import * as os from "os" | ||
import { arePathsEqual, getReadablePath } from "./path" | ||
|
||
suite("Path Utils", () => { | ||
test("arePathsEqual handles undefined paths", () => { | ||
assert.strictEqual(arePathsEqual(undefined, undefined), true) | ||
assert.strictEqual(arePathsEqual("foo", undefined), false) | ||
assert.strictEqual(arePathsEqual(undefined, "foo"), false) | ||
}) | ||
|
||
test("arePathsEqual handles case sensitivity based on platform", () => { | ||
if (process.platform === "win32") { | ||
assert.strictEqual(arePathsEqual("FOO/BAR", "foo/bar"), true) | ||
} else { | ||
assert.strictEqual(arePathsEqual("FOO/BAR", "foo/bar"), false) | ||
} | ||
}) | ||
|
||
test("arePathsEqual handles normalized paths", () => { | ||
assert.strictEqual(arePathsEqual("/tmp/./dir", "/tmp/../tmp/dir"), true) | ||
assert.strictEqual(arePathsEqual("/tmp/./dir", "/tmp/../dir"), false) | ||
}) | ||
|
||
test("getReadablePath handles desktop path", () => { | ||
const desktop = path.join(os.homedir(), "Desktop") | ||
const testPath = path.join(desktop, "test.txt") | ||
assert.strictEqual(getReadablePath(desktop, "test.txt"), testPath.replace(/\\/g, "/")) | ||
}) | ||
|
||
test("getReadablePath shows relative paths within cwd", () => { | ||
const cwd = "/home/user/project" | ||
const filePath = "/home/user/project/src/file.txt" | ||
assert.strictEqual(getReadablePath(cwd, filePath), "src/file.txt") | ||
}) | ||
|
||
test("getReadablePath shows basename when path equals cwd", () => { | ||
const cwd = "/home/user/project" | ||
assert.strictEqual(getReadablePath(cwd, cwd), "project") | ||
}) | ||
|
||
test("getReadablePath shows absolute path when outside cwd", () => { | ||
const cwd = "/home/user/project" | ||
const filePath = "/home/user/other/file.txt" | ||
assert.strictEqual(getReadablePath(cwd, filePath), filePath) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
// This separate tsconfig is necessary because VS Code's test runner requires CommonJS modules, | ||
// while our main project uses ES Modules (ESM). This config inherits most settings from the base | ||
// tsconfig.json but overrides the module system for test files only. This doesn't affect how | ||
// tests interact with the main codebase - it only changes how the test files themselves are | ||
// compiled to make them compatible with VS Code's test runner. | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"moduleResolution": "node" | ||
}, | ||
"include": ["src/**/*.test.ts"] | ||
} |