mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 19:59:37 +00:00
feat: jest testing (#13)
This commit is contained in:
parent
89ed852231
commit
3b1c4465db
7 changed files with 6142 additions and 3 deletions
44
tests/baseClient.test.ts
Normal file
44
tests/baseClient.test.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { ClasschartsStudentClient } from "../src";
|
||||
import { code, dob } from "./config.json";
|
||||
import "jest-extended";
|
||||
const client = new ClasschartsStudentClient(code, dob);
|
||||
|
||||
test("client logs in with correct credentials", () => {
|
||||
return expect(client.login()).resolves.not.toThrow();
|
||||
});
|
||||
|
||||
test("client fails to login with incorrect credentials", () => {
|
||||
const fakeClient = new ClasschartsStudentClient("rewrew", "123");
|
||||
return expect(fakeClient.login()).rejects.toThrowError();
|
||||
});
|
||||
|
||||
test("client returns student data", () => {
|
||||
return expect(client.getStudentInfo()).resolves.toBeObject();
|
||||
});
|
||||
|
||||
test("client returns activity data", () => {
|
||||
return expect(client.getActivity()).resolves.toBeArray();
|
||||
});
|
||||
|
||||
test("client returns full activity", () => {
|
||||
return client
|
||||
.getFullActivity({ from: "2000-01-01", to: "2022-01-01" })
|
||||
.then((data) => {
|
||||
let valid = false;
|
||||
if (data.length > 50) valid = true;
|
||||
expect(valid).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
test("client returns behaviour data", () => {
|
||||
pending();
|
||||
return expect(client.getBehaviour()).resolves.toBeObject();
|
||||
});
|
||||
|
||||
test("client returns homework data", () => {
|
||||
return expect(client.listHomeworks()).resolves.toBeArray();
|
||||
});
|
||||
|
||||
test("client returns badges", () => {
|
||||
expect(client.getBadges()).resolves.toBeArray();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue