mirror of
https://github.com/coder/code-server.git
synced 2024-12-22 17:21:43 +03:00
refactor: move jest and add package.json to /test
This commit is contained in:
parent
646ee3ad7f
commit
883dd13850
@ -6,8 +6,9 @@ main() {
|
||||
|
||||
cd test/test-plugin
|
||||
make -s out/index.js
|
||||
cd "$OLDPWD"
|
||||
yarn jest "$@"
|
||||
cd "$OLDPWD/test"
|
||||
yarn
|
||||
yarn test "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
@ -15,8 +15,7 @@
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"newLine": "lf",
|
||||
"skipLibCheck": true
|
||||
"newLine": "lf"
|
||||
},
|
||||
"include": [
|
||||
"**/*.ts"
|
||||
|
@ -6,6 +6,6 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export function isWeb(): boolean {
|
||||
// NOTE@coder: Remove unused ts-expect-error directive which causes tsc to error.
|
||||
// @ts-expect-error
|
||||
return typeof navigator !== 'undefined' && vscode.env.uiKind === vscode.UIKind.Web;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@
|
||||
"@types/express": "^4.17.8",
|
||||
"@types/fs-extra": "^8.0.1",
|
||||
"@types/http-proxy": "^1.17.4",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/js-yaml": "^3.12.3",
|
||||
"@types/node": "^12.12.7",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
@ -55,7 +54,6 @@
|
||||
"eslint-config-prettier": "^6.0.0",
|
||||
"eslint-plugin-import": "^2.18.2",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"jest": "^26.6.3",
|
||||
"leaked-handles": "^5.2.0",
|
||||
"parcel-bundler": "^1.12.4",
|
||||
"prettier": "^2.0.5",
|
||||
|
22
test/package.json
Normal file
22
test/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node-fetch": "^2.5.8",
|
||||
"@types/supertest": "^2.0.10",
|
||||
"jest": "^26.6.3",
|
||||
"node-fetch": "^2.6.1",
|
||||
"supertest": "^6.1.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.3"
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import { logger } from "@coder/logger"
|
||||
import * as assert from "assert"
|
||||
import * as express from "express"
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
@ -15,7 +14,7 @@ describe("plugin", () => {
|
||||
let papi: PluginAPI
|
||||
let s: httpserver.HttpServer
|
||||
|
||||
before(async () => {
|
||||
beforeAll(async () => {
|
||||
papi = new PluginAPI(logger, `${path.resolve(__dirname, "test-plugin")}:meow`)
|
||||
await papi.loadPlugins()
|
||||
|
||||
@ -27,16 +26,16 @@ describe("plugin", () => {
|
||||
await s.listen(app)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
afterAll(async () => {
|
||||
await s.close()
|
||||
})
|
||||
|
||||
it("/api/applications", async () => {
|
||||
const resp = await s.fetch("/api/applications")
|
||||
assert.equal(200, resp.status)
|
||||
expect(resp.status).toBe(200)
|
||||
const body = await resp.json()
|
||||
logger.debug(`${JSON.stringify(body)}`)
|
||||
assert.deepEqual(body, [
|
||||
expect(body).toStrictEqual([
|
||||
{
|
||||
name: "Test App",
|
||||
version: "4.0.0",
|
||||
@ -65,8 +64,8 @@ describe("plugin", () => {
|
||||
encoding: "utf8",
|
||||
})
|
||||
const resp = await s.fetch("/test-plugin/test-app")
|
||||
assert.equal(200, resp.status)
|
||||
expect(resp.status).toBe(200)
|
||||
const body = await resp.text()
|
||||
assert.equal(body, indexHTML)
|
||||
expect(body).toBe(indexHTML)
|
||||
})
|
||||
})
|
||||
|
@ -1,4 +1,3 @@
|
||||
import * as assert from "assert"
|
||||
import * as express from "express"
|
||||
import * as httpserver from "./httpserver"
|
||||
import * as integration from "./integration"
|
||||
@ -8,7 +7,7 @@ describe("proxy", () => {
|
||||
const nhooyrDevServer = new httpserver.HttpServer()
|
||||
let proxyPath: string
|
||||
|
||||
before(async () => {
|
||||
beforeAll(async () => {
|
||||
const e = express.default()
|
||||
await nhooyrDevServer.listen(e)
|
||||
e.get("/wsup", (req, res) => {
|
||||
@ -20,7 +19,7 @@ describe("proxy", () => {
|
||||
})
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
afterAll(async () => {
|
||||
await nhooyrDevServer.close()
|
||||
})
|
||||
|
||||
@ -34,14 +33,16 @@ describe("proxy", () => {
|
||||
it("should rewrite the base path", async () => {
|
||||
;[, , codeServer] = await integration.setup(["--auth=none"], "")
|
||||
const resp = await codeServer.fetch(proxyPath)
|
||||
assert.equal(resp.status, 200)
|
||||
assert.equal(await resp.json(), "asher is the best")
|
||||
expect(resp.status).toBe(200)
|
||||
const json = await resp.json()
|
||||
expect(json).toBe("asher is the best")
|
||||
})
|
||||
|
||||
it("should not rewrite the base path", async () => {
|
||||
;[, , codeServer] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
|
||||
const resp = await codeServer.fetch(proxyPath)
|
||||
assert.equal(resp.status, 200)
|
||||
assert.equal(await resp.json(), "joe is the best")
|
||||
expect(resp.status).toBe(200)
|
||||
const json = await resp.json()
|
||||
expect(json).toBe("joe is the best")
|
||||
})
|
||||
})
|
||||
|
@ -1,4 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["./**/*.ts"]
|
||||
"compilerOptions": {
|
||||
"typeRoots": ["node_modules/@types", "../typings"],
|
||||
"composite": true
|
||||
},
|
||||
"include": ["./**/*.ts"],
|
||||
"exclude": ["node_modules/**"],
|
||||
"types": ["jest"]
|
||||
}
|
||||
|
3760
test/yarn.lock
Normal file
3760
test/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -15,9 +15,9 @@
|
||||
"sourceMap": true,
|
||||
"tsBuildInfoFile": "./.cache/tsbuildinfo",
|
||||
"incremental": true,
|
||||
"rootDir": "./src",
|
||||
"typeRoots": ["./node_modules/@types", "./typings"],
|
||||
"downlevelIteration": true
|
||||
},
|
||||
"include": ["./src/**/*.ts"]
|
||||
"include": ["./src/**/*.ts"],
|
||||
"exclude": ["test", "lib", "ci", "doc"]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user