Unit Testing: Automatic Thoughts Response - CBTYoung/Documentation GitHub Wiki

import { AutomaticThoughtsResponse } from "../../../src/architecture/business_layer/modules/AutomaticThoughtsResponse";

describe("AutomaticThoughtsResponse Summary tests", () => {
       
    test('checking getsummary with response', () =>{
        const date = new Date(Date.now());
        const thought ="I'm pretty";
        const auto = new AutomaticThoughtsResponse(date, thought);
        const res1 = "yes u are";
        auto.addResponse(res1);
        expect(auto.getSummary())
        .toBe(date.toString()+":\n"+thought+"\nResponses:\n"+res1);
    });

    test('checking getsummary with two thoughts', () =>{
        const date = new Date(Date.now());
        const thought ="I'm pretty";
        const auto = new AutomaticThoughtsResponse(date, thought);
        const res1 = "yes u are";
        const res2 = "beauty";

        auto.addResponse(res1);
        auto.addResponse(res2);

        expect(auto.getSummary())
        .toBe(date.toString()+":\n"+thought+"\nResponses:\n"+res1+"\n"+res2);
    });

    test('checking getsummary with two thoughts with delete ', () =>{
        const date = new Date(Date.now());
        const thought ="I'm pretty";
        const auto = new AutomaticThoughtsResponse(date, thought);
        const res1 = "yes u are";
        const res2 = "beauty";
        const res3 = "ful";
        auto.addResponse(res1);
        auto.addResponse(res2);
        auto.addResponse(res3);
        auto.deleteResponse(0);

        expect(auto.getSummary())
        .toBe(date.toString()+":\n"+thought+"\nResponses:\n"+res2+"\n"+res3);
    });
});