summary refs log tree commit diff
path: root/api/tests
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-30 15:13:18 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-30 15:13:18 +1000
commitc2931f61aa0adb682ab023d85ba599099024d62b (patch)
tree86de9071cbded565fe9e082bd2cc6c611a926c6c /api/tests
parentGuild join messages (diff)
parentOop, deprecated typeorm call (diff)
downloadserver-c2931f61aa0adb682ab023d85ba599099024d62b.tar.xz
Merge branch 'staging' into dev/Maddy/feat/welcomeMessages
Diffstat (limited to '')
-rw-r--r--tests/routes.test.ts (renamed from api/tests/routes.test.ts)22
-rw-r--r--tests/routes/auth/login.test.js (renamed from api/tests/routes/auth/login.test.js)0
-rw-r--r--tests/routes/auth/register.test.js (renamed from api/tests/routes/auth/register.test.js)0
-rw-r--r--tests/routes/ping.test.js (renamed from api/tests/routes/ping.test.js)0
4 files changed, 11 insertions, 11 deletions
diff --git a/api/tests/routes.test.ts b/tests/routes.test.ts

index 35d74a94..51c068b5 100644 --- a/api/tests/routes.test.ts +++ b/tests/routes.test.ts
@@ -1,13 +1,13 @@ // TODO: check every route based on route() parameters: https://github.com/fosscord/fosscord-server/issues/308 // TODO: check every route with different database engine -import getRouteDescriptions from "../jest/getRouteDescriptions"; -import { join } from "path"; -import fs from "fs"; +import { Channel, Event, events, Guild, User } from "@fosscord/util"; import Ajv from "ajv"; import addFormats from "ajv-formats"; +import fs from "fs"; import fetch from "node-fetch"; -import { Event, User, events, Guild, Channel } from "@fosscord/util"; +import { join } from "path"; +import getRouteDescriptions from "../jest/getRouteDescriptions"; const SchemaPath = join(__dirname, "..", "assets", "schemas.json"); const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" })); @@ -23,10 +23,10 @@ export const ajv = new Ajv({ }); addFormats(ajv); -var token: string; -var user: User; -var guild: Guild; -var channel: Channel; +let token: string; +let user: User; +let guild: Guild; +let channel: Channel; const request = async (path: string, opts: any = {}): Promise<any> => { const response = await fetch(`http://localhost:3001/api${path}`, { @@ -41,7 +41,7 @@ const request = async (path: string, opts: any = {}): Promise<any> => { }); if (response.status === 204) return; - var data = await response.text(); + let data = await response.text(); try { data = JSON.parse(data); if (response.status >= 400) throw data; @@ -95,13 +95,13 @@ describe("Automatic unit tests with route description middleware", () => { } const urlPath = path.replace(":id", user.id).replace(":guild_id", guild.id).replace(":channel_id", channel.id) || route.test?.path; - var validate: any; + let validate: any; if (route.test.body) { validate = ajv.getSchema(route.test.body); if (!validate) return done(new Error(`Response schema ${route.test.body} not found`)); } - var body = ""; + let body = ""; let eventEmitted = Promise.resolve(); if (route.test.event) { diff --git a/api/tests/routes/auth/login.test.js b/tests/routes/auth/login.test.js
index d4b52444..d4b52444 100644 --- a/api/tests/routes/auth/login.test.js +++ b/tests/routes/auth/login.test.js
diff --git a/api/tests/routes/auth/register.test.js b/tests/routes/auth/register.test.js
index 5d7b4eaa..5d7b4eaa 100644 --- a/api/tests/routes/auth/register.test.js +++ b/tests/routes/auth/register.test.js
diff --git a/api/tests/routes/ping.test.js b/tests/routes/ping.test.js
index 6fa4b160..6fa4b160 100644 --- a/api/tests/routes/ping.test.js +++ b/tests/routes/ping.test.js