added tests

master
Tudor Stanciu 2023-02-10 02:20:52 +02:00
parent 590afef989
commit 6b3385af6a
6 changed files with 1145 additions and 79 deletions

2
.gitignore vendored
View File

@ -21,3 +21,5 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
example/package-lock.json example/package-lock.json
coverage

2
.vscode/launch.json vendored
View File

@ -1,6 +1,6 @@
{ {
"name": "Jest file", "name": "Jest file",
"type": "pwa-node", "type": "node",
"request": "launch", "request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/jest", "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/jest",
"args": ["${fileBasenameNoExtension}", "--runInBand", "--watch", "--coverage=false", "--no-cache"], "args": ["${fileBasenameNoExtension}", "--runInBand", "--watch", "--coverage=false", "--no-cache"],

View File

@ -3,5 +3,14 @@
"^.+\\.(t|j)sx?$": "ts-jest" "^.+\\.(t|j)sx?$": "ts-jest"
}, },
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"] "moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
"collectCoverage": false,
"coverageThreshold": {
"global": {
"branches": 50,
"functions": 50,
"lines": 50,
"statements": 50
}
}
} }

1191
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@
"devDependencies": { "devDependencies": {
"@types/jest": "^29.4.0", "@types/jest": "^29.4.0",
"jest": "^29.4.1", "jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.2",
"prettier": "^2.8.3", "prettier": "^2.8.3",
"ts-jest": "^29.0.5", "ts-jest": "^29.0.5",
"tslint": "^6.1.3", "tslint": "^6.1.3",

View File

@ -0,0 +1,15 @@
/**
* @jest-environment jsdom
*/
import { fetch, invalidate } from "../client";
test("Tuitio empty storage", () => {
const result = fetch();
expect(result.token).toBeNull();
expect(result.userName).toBeNull();
});
test("Tuitio storage invalidation", () => {
expect(invalidate()).toBe(void 0);
});