-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmount.test.js
More file actions
71 lines (61 loc) · 2.71 KB
/
Copy pathmount.test.js
File metadata and controls
71 lines (61 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import "../helpers/env.js"
import assert from "node:assert/strict"
import { afterEach, beforeEach, describe, it } from "node:test"
import fs from "node:fs"
import request from "supertest"
import app from "../../app.js"
const originalFetch = global.fetch
beforeEach(() => {
global.fetch = async () => ({
ok: false,
status: 401,
text: async () => "Unauthorized",
headers: { get: () => "text/plain" }
})
})
afterEach(() => {
global.fetch = originalFetch
})
async function routeExists(routes, method = "post") {
const responses = await Promise.all(
routes.map(route => request(app)[method](route).set("Content-Type", "application/json").send({}))
)
return responses.every(response => response.statusCode !== 404)
}
describe("Check that the expected TinyNode create route patterns are registered.", () => {
it("'/app/create' and '/create' are registered routes in the app. __exists __core", async () => {
assert.equal(await routeExists(["/create", "/app/create"]), true)
})
})
describe("Check that the expected TinyNode query route patterns are registered.", () => {
it("'/app/query' and '/query' are registered routes in the app. __exists __core", async () => {
assert.equal(await routeExists(["/query", "/app/query"]), true)
})
})
describe("Check that the expected TinyNode update route patterns are registered.", () => {
it("'/app/update' and '/update' are registered routes in the app. __exists __core", async () => {
assert.equal(await routeExists(["/update", "/app/update"], "put"), true)
})
})
describe("Check that the expected TinyNode overwrite route patterns are registered.", () => {
it("'/app/overwrite' and '/overwrite' are registered routes in the app. __exists __core", async () => {
assert.equal(await routeExists(["/overwrite", "/app/overwrite"], "put"), true)
})
})
describe("Combined unit tests for the '/delete' route.", () => {
it("'/app/delete' and '/delete' are registered routes in the app. __exists __core", async () => {
assert.equal(await routeExists(["/delete", "/app/delete"], "delete"), true)
})
})
describe("Check to see that critical repo files are present", () => {
it("root folder files", () => {
const filePath = "./"
assert.equal(fs.existsSync(`${filePath}CODEOWNERS`), true)
assert.equal(fs.existsSync(`${filePath}CONTRIBUTING.md`), true)
assert.equal(fs.existsSync(`${filePath}README.md`), true)
assert.equal(fs.existsSync(`${filePath}.gitignore`), true)
assert.equal(fs.existsSync(`${filePath}package.json`), true)
assert.equal(fs.existsSync(`${filePath}.github/workflows/shared_openapi_sync.yaml`), true)
assert.equal(fs.existsSync(`${filePath}openapi/components/tinynode-shared-components.openapi.yaml`), true)
})
})