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 = {