Unit Testing: Patient V2 - CBTYoung/Documentation GitHub Wiki
import { PatientAPI } from "../../src/architecture/service_layer/Patient";
import { isOk } from "../../src/architecture/service_layer/Result";
const username: string = "hello";
const password: string = "goodbye";
const patient: PatientAPI = PatientAPI.Instance;
describe("Patient service layer tests", () => {
test('checking patient username without login in service', () =>{
const name = patient.getUsername();
if(isOk(name)){
throw new Error("not ok");
}
expect(name.message).toBe("Not a Patient");
});
test('checking patient username after login in service', () =>{
patient.continueAsPatient({username: username, password: password});
const name = patient.getUsername();
if(isOk(name)){
expect(name.value).toBe(username)
}
else
throw new Error("not ok");
});
});