-
Notifications
You must be signed in to change notification settings - Fork 0
Unit Testing: Patient V3
goldyuva edited this page Jun 9, 2023
·
2 revisions
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");
});
});When a user tries to become a Patient, but he didn't log in.
In that case, the system sends a message saying: "Not a Patient". If we are returned a Patient object instead, we throw an error.
When a user tries to become a Patient, and he did log in.
In that case, the system sends a Patient object back, and we check it's username to see if it's correct. If we are returned an object that is not OK, we throw an error.