-
Notifications
You must be signed in to change notification settings - Fork 0
Unit Testing: Active Fill V3
goldyuva edited this page Jun 9, 2023
·
3 revisions
import { ActiveFill } from "../../../../src/architecture/business_layer/modules/ReportStrategies/ActiveFill";
import { bodyParts, BodyPartSelection } from "../../../../src/architecture/business_layer/modules/ReportStrategies/BodyPartSelection";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);
});
});When we try to add a report with no event, it should throw an error of type emptyEventError.
When we try to add a report with no event but all other variables filled, it should throw an error of type emptyEventError.
When we try to add a report with an event and all other variables filled, it should not throw an error of type emptyEventError.
When we try to add a report with an event body parts that we selected, it should not throw an error of type emptyEventError.
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());
});
});
We want to get a summary of all the correct data we enter, so we expect to see it formatted.
If we only have event data, we expect to get only the event.
We want to see if we get partial summary with only partial data filled.