2023-04-07 13:47:08 +01:00
|
|
|
import { StudentClient } from "../src";
|
2022-04-10 11:48:24 +01:00
|
|
|
import { code, dob } from "./config.json";
|
|
|
|
|
import "jest-extended";
|
2023-04-07 13:47:08 +01:00
|
|
|
const client = new StudentClient(code, dob);
|
2022-09-23 18:47:23 +00:00
|
|
|
jest.setTimeout(10000);
|
2022-04-10 11:48:24 +01:00
|
|
|
|
|
|
|
|
test("client logs in with correct credentials", () => {
|
|
|
|
|
return expect(client.login()).resolves.not.toThrow();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client fails to login with incorrect credentials", () => {
|
2023-04-07 13:47:08 +01:00
|
|
|
const fakeClient = new StudentClient("rewrew", "123");
|
2022-04-10 11:48:24 +01:00
|
|
|
return expect(fakeClient.login()).rejects.toThrowError();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client returns student data", () => {
|
|
|
|
|
return expect(client.getStudentInfo()).resolves.toBeObject();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client returns activity data", () => {
|
2023-04-07 13:47:08 +01:00
|
|
|
return expect(client.getActivity()).resolves.toBeObject();
|
2022-04-10 11:48:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client returns full activity", () => {
|
|
|
|
|
return client
|
2022-09-23 19:40:32 +01:00
|
|
|
.getFullActivity({ from: "2022-01-01", to: "2022-09-01" })
|
2022-04-10 11:48:24 +01:00
|
|
|
.then((data) => {
|
|
|
|
|
let valid = false;
|
2022-09-23 18:47:23 +00:00
|
|
|
if (data.length > 0) valid = true;
|
2022-04-10 11:48:24 +01:00
|
|
|
expect(valid).toBeTrue();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client returns behaviour data", () => {
|
|
|
|
|
return expect(client.getBehaviour()).resolves.toBeObject();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client returns homework data", () => {
|
2023-04-07 13:47:08 +01:00
|
|
|
return expect(client.getHomeworks()).resolves.toBeObject();
|
2022-04-10 11:48:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("client returns badges", () => {
|
2023-04-07 13:47:08 +01:00
|
|
|
expect(client.getBadges()).resolves.toBeObject();
|
2022-04-10 11:48:24 +01:00
|
|
|
});
|