Unit Testing: Body Part Selection V3 - CBTYoung/Documentation GitHub Wiki

1. Body Part Selection Tests:

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

describe("Body Part selection tests", () => {
    test('isStringBodyPart correct input', () => {
        const part: string = bodyParts.hand;
        const result = BodyPartSelection.isStringBodyPart(part);
        expect(result).toBeInstanceOf(BodyPartSelection);
    })

    test('adding empty event with all other variables filled', () => {
        const part: string = "poop";
        const result = BodyPartSelection.isStringBodyPart(part);
        expect(result).not.toBeInstanceOf(BodyPartSelection);
    })
});

1.1. isStringBodyPart Correct Input

We check if we give a body part to the Body Part Selection module to be returned as an instance of BodyPartSelection.

1.2. Adding Empty Event With All Other Variables Filled

We give a body part to a report with no event and we expect the result to not be of type BodyPartSelection.