From 590afef9894bc04b29c8159c66b359945e078e0f Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Fri, 10 Feb 2023 01:45:27 +0200 Subject: [PATCH] Tuitio client tests --- .vscode/launch.json | 14 ++++++++++++++ .../{Tuitio.test.ts => TuitioClient.test.ts} | 6 ++++++ src/client.ts | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json rename src/__tests__/{Tuitio.test.ts => TuitioClient.test.ts} (78%) diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3752d92 --- /dev/null +++ b/.vscode/launch.json @@ -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" + } +} diff --git a/src/__tests__/Tuitio.test.ts b/src/__tests__/TuitioClient.test.ts similarity index 78% rename from src/__tests__/Tuitio.test.ts rename to src/__tests__/TuitioClient.test.ts index b689dba..d736877 100644 --- a/src/__tests__/Tuitio.test.ts +++ b/src/__tests__/TuitioClient.test.ts @@ -1,5 +1,6 @@ import { getUrlTemplates } from "../config"; import { combineUrls } from "../utils"; +import { TuitioClient } from "../client"; test("Combine urls with trailing slash", () => { 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("{password}"); }); + +test("Tuitio client initialization", () => { + const result = new TuitioClient("https://test.com/api"); + expect(result.baseUrl).toBe("https://test.com/api"); +}); diff --git a/src/client.ts b/src/client.ts index d2a523d..6657375 100644 --- a/src/client.ts +++ b/src/client.ts @@ -51,7 +51,7 @@ const invalidate = (): void => { } }; -type TuitioState = { token: string; userName: string }; +export type TuitioState = { token: string; userName: string }; const fetch = (): TuitioState => { const data = {