Skip to content

Commit

Permalink
add some DiaryHelper tests
Browse files Browse the repository at this point in the history
testing the testing framework :)

my goal is to test the normal cases and the edge cases

ex: isMultiDay - test one expecting true, one expecting false, and one with invalid input (so false)
  • Loading branch information
Abby Wheelis committed Sep 19, 2023
1 parent 856b2d6 commit 4604405
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion www/__tests__/diaryHelper.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import { getFormattedDate } from "../js/diary/diaryHelper";
import { getFormattedDate, motionTypeOf, isMultiDay } from "../js/diary/diaryHelper";

it('returns a formatted date', () => {
expect(getFormattedDate("2023-09-18T00:00:00-07:00")).toBe("Mon September 18, 2023");
expect(getFormattedDate("")).toBeUndefined();
expect(getFormattedDate("2023-09-18T00:00:00-07:00", "2023-09-21T00:00:00-07:00")).toBe("Mon September 18, 2023 - Thu September 21, 2023");
});

it("returns a MotionType object", () => {
expect(motionTypeOf("WALKING")).toEqual({ name: "WALKING", icon: "walk", color: '#0068a5' });
// expect(motionTypeOf("MotionTypes.WALKING")).toEqual({ name: "WALKING", icon: "walk", color: '#0068a5' }); //failing but I don't know why
expect(motionTypeOf("I made this type up")).toEqual({ name: "UNKNOWN", icon: "help", color: '#484848'});
});

it('returns true/false is multi day', () => {
expect(isMultiDay("2023-09-18T00:00:00-07:00", "2023-09-19T00:00:00-07:00")).toBeTruthy();
expect(isMultiDay("2023-09-18T00:00:00-07:00", "2023-09-18T00:00:00-09:00")).toBeFalsy();
expect(isMultiDay("", "2023-09-18T00:00:00-09:00")).toBeFalsy();
});

0 comments on commit 4604405

Please sign in to comment.