diff options
author | Kirill Dubovitskiy <kirill2003de@gmail.com> | 2023-08-07 14:54:37 -0700 |
---|---|---|
committer | Kirill Dubovitskiy <kirill2003de@gmail.com> | 2023-08-07 15:25:11 -0700 |
commit | c12be8daf60cd3d5554e9f5465aa5e8a5187d288 (patch) | |
tree | 9e92dc4a10004ec13cb2bfb45be8828bd2fb4dc6 /extension/src/test-suite | |
parent | 0fc56305d762181519569098a99faa255f9cd24f (diff) | |
download | sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.tar.gz sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.tar.bz2 sncontinue-c12be8daf60cd3d5554e9f5465aa5e8a5187d288.zip |
Refactor test scripts and update build configurations
- Added a new esbuild for:
- bundling test runners (run tests on vscode + mocha runner)
- bundling all tests in the project
- Some opinionated renamings / moving test related things around
- Changed output directory in tsconfig to avoid overriding the entire out directory - bundles tests also go there
Some poking around trying to deprecate jest as it is not used and mocha is more often used for vscode extension testing.
Though I assume jest was added to test GUI within extension.
This work was started because there are compilation issues with the current setup and neither of the tests are actually working so figured getting one to a working spot is a good start
Diffstat (limited to 'extension/src/test-suite')
-rw-r--r-- | extension/src/test-suite/environmentSetup.test.ts | 19 | ||||
-rw-r--r-- | extension/src/test-suite/extension.test.ts | 16 | ||||
-rw-r--r-- | extension/src/test-suite/util.test.ts | 18 |
3 files changed, 53 insertions, 0 deletions
diff --git a/extension/src/test-suite/environmentSetup.test.ts b/extension/src/test-suite/environmentSetup.test.ts new file mode 100644 index 00000000..7610e70d --- /dev/null +++ b/extension/src/test-suite/environmentSetup.test.ts @@ -0,0 +1,19 @@ +import { test, describe } from "mocha"; +import * as assert from "assert"; + +import { getContinueServerUrl } from "../bridge"; +import { startContinuePythonServer } from "../activation/environmentSetup"; +import fetch from "node-fetch"; + +describe("Can start python server", () => { + test("Can start python server", async () => { + await startContinuePythonServer(); + + await new Promise((resolve) => setTimeout(resolve, 50)); + + // Check if server is running + const serverUrl = getContinueServerUrl(); + const response = await fetch(`${serverUrl}/health`); + assert.equal(response.status, 200); + }); +}); diff --git a/extension/src/test-suite/extension.test.ts b/extension/src/test-suite/extension.test.ts new file mode 100644 index 00000000..890820b2 --- /dev/null +++ b/extension/src/test-suite/extension.test.ts @@ -0,0 +1,16 @@ +import { test, describe } from "mocha"; +import * as assert from "assert"; + +// You can import and use all API from the 'vscode' module +// as well as import your extension to test it +import * as vscode from "vscode"; +// import * as myExtension from '../../extension'; + +describe("Extension Test Suite", () => { + vscode.window.showInformationMessage("Start all tests."); + + test("Sample test", () => { + assert.strictEqual(-1, [1, 2, 3].indexOf(5)); + assert.strictEqual(-1, [1, 2, 3].indexOf(0)); + }); +}); diff --git a/extension/src/test-suite/util.test.ts b/extension/src/test-suite/util.test.ts new file mode 100644 index 00000000..2b301b0c --- /dev/null +++ b/extension/src/test-suite/util.test.ts @@ -0,0 +1,18 @@ +import { test, describe } from "mocha"; +import assert from "assert"; +import { convertSingleToDoubleQuoteJSON } from "../util/util"; + +describe("utils.ts", () => { + test("convertSingleToDoubleQuoteJson", () => { + let pairs = [ + [`{'a': 'b'}`, `{"a": "b"}`], + [`{'a': "b", "c": 'd'}`, `{"a": "b", "c": "d"}`], + [`{'a': '\\'"'}`, `{"a": "'\\""}`], + ]; + for (let pair of pairs) { + let result = convertSingleToDoubleQuoteJSON(pair[0]); + assert(result === pair[1]); + JSON.parse(result); + } + }); +}); |