Tuitio client tests

master
Tudor Stanciu 2023-02-10 01:45:27 +02:00
parent 0296973977
commit 590afef989
3 changed files with 21 additions and 1 deletions

14
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
"name": "Jest file",
"type": "pwa-node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/jest",
"args": ["${fileBasenameNoExtension}", "--runInBand", "--watch", "--coverage=false", "--no-cache"],
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}

View File

@ -1,5 +1,6 @@
import { getUrlTemplates } from "../config"; import { getUrlTemplates } from "../config";
import { combineUrls } from "../utils"; import { combineUrls } from "../utils";
import { TuitioClient } from "../client";
test("Combine urls with trailing slash", () => { test("Combine urls with trailing slash", () => {
const result = combineUrls("https://test.com/api/", "/test"); const result = combineUrls("https://test.com/api/", "/test");
@ -18,3 +19,8 @@ test("Get url templates", () => {
expect(result.authentication).toContain("{username}"); expect(result.authentication).toContain("{username}");
expect(result.authentication).toContain("{password}"); expect(result.authentication).toContain("{password}");
}); });
test("Tuitio client initialization", () => {
const result = new TuitioClient("https://test.com/api");
expect(result.baseUrl).toBe("https://test.com/api");
});

View File

@ -51,7 +51,7 @@ const invalidate = (): void => {
} }
}; };
type TuitioState = { token: string; userName: string }; export type TuitioState = { token: string; userName: string };
const fetch = (): TuitioState => { const fetch = (): TuitioState => {
const data = { const data = {