-
Notifications
You must be signed in to change notification settings - Fork 0
Unit Testing: Automatic Thoughts V3
goldyuva edited this page Jun 9, 2023
·
2 revisions
import { AutomaticThoughts } from "../../../src/architecture/business_layer/modules/AutomaticThoughts";
const thought ="I'm pretty";
const setTh ="I'm pretty sad";
const date = new Date(Date.now());
let auto = new AutomaticThoughts(thought);
const response = "rsponse with important data";
const responseDate = new Date(Date.now()+1000);
function formatSummaryOneThought(date:Date,thought:string)
{
return "Thought from "+date.toString()+":\n"+thought;
}
function formatSummaryOneThoughtWithResponse(date:Date,thought:string,resDate:Date,response:string)
{
return "Thought from "+date.toString()+":\n"+thought+ "\nResponse from "+new Date(resDate).getDay()+"/"+new Date(resDate).getMonth()+ "/"+new Date(resDate).getFullYear()+": "+response;
}describe("AutomaticThoughts Summary tests", () => {
beforeEach(()=>{
auto = new AutomaticThoughts(thought);
})
test('checking getsummary with thought', () =>{
expect(auto.getSummary())
.toBe(formatSummaryOneThought(date,thought));
});
test('checking getsummary with set thought', () =>{
auto.setThought(setTh);
expect(auto.getSummary())
.toBe(formatSummaryOneThought(date,setTh));
});
test('checking getsummary with response', () =>{
expect(auto.getSummary())
.toBe(formatSummaryOneThought(date,thought));
auto.addRepsonse(responseDate,response);
expect(auto.getSummary())
.toBe(formatSummaryOneThoughtWithResponse(date,thought,responseDate,response));
});
});We want to check if we get the same thought formatted as we put in the report.
We expect their results to be identical.
After we set a new thought, We want to check if we get the same thought formatted in the updated report.
We expect their results to be identical.
We want to check if we get the same response formatted as we put in the report.
We expect their results to be identical.