Unit Testing: Active Fill V3 - CBTYoung/Documentation GitHub Wiki

import { ActiveFill } from "../../../../src/architecture/business_layer/modules/ReportStrategies/ActiveFill";
import { bodyParts, BodyPartSelection } from "../../../../src/architecture/business_layer/modules/ReportStrategies/BodyPartSelection";

1. Active Fill Tests


describe("Active Fill tests", () => {
   

    test('adding empty event', () => {
        expect(() => new ActiveFill("")).toThrow(ActiveFill.emptyEventError);
    });
    test('adding empty event with all other variables filled', () => {
        expect(() => new ActiveFill("", [], "stomach", "my", "world")).toThrow(ActiveFill.emptyEventError);
    });

    test('adding correct event with all other variables filled', () => {
        expect(() => new ActiveFill("feeling good", [], "stomach", "my", "world")).not.toThrow(ActiveFill.emptyEventError);
    });

    test('adding correct event with body part selection', () => {
        expect(() => new ActiveFill("feeling good", [], "stomach", "my", "world")).not.toThrow(ActiveFill.emptyEventError);
    });
});

1.1: Adding Empty Event

When we try to add a report with no event, it should throw an error of type emptyEventError.

1.2: Adding Empty Event With All Other Variables filled

When we try to add a report with no event but all other variables filled, it should throw an error of type emptyEventError.

1.3: Adding Correct Event With All Other Variables filled

When we try to add a report with an event and all other variables filled, it should not throw an error of type emptyEventError.

1.4: Adding Correct Event With Body Part Selection

When we try to add a report with an event body parts that we selected, it should not throw an error of type emptyEventError.

2. Active Fill Summary Tests

describe("Active Fill Summary tests", () => {
    
    test('checking get summary with all string data', () =>{
        expect("The event:feeling good\nThe bodyPart: stomach\nThe thought: my\nThe response: world")
        .toBe(new ActiveFill("feeling good", [], "stomach", "my", "world").getSummary());
    });

    test('checking get summary with only event data', () =>{
        expect("The event:feeling good")
        .toBe(new ActiveFill("feeling good").getSummary());
    });

    
    test('checking get summary with only event and emotion data', () =>{
        expect("The event:feeling good\nThe bodyPart: stomach")
        .toBe(new ActiveFill("feeling good",[],"stomach").getSummary());
    });

    
    test('checking get summary with only event and body part data', () =>{
        expect("The event:feeling good\nThe bodyPart: stomach")
        .toBe(new ActiveFill("feeling good",[],"stomach").getSummary());
    });

});

2.1. Checking Get Summary With All String Data

We want to get a summary of all the correct data we enter, so we expect to see it formatted.

2.2. Checking Get Summary With Only Event Data

If we only have event data, we expect to get only the event.

2.3. Checking Get Summary With Only Event And Emotion Data

We want to see if we get partial summary with only partial data filled.