From 4604405116916ab323bb17e19fc3b4fb7d66668c Mon Sep 17 00:00:00 2001 From: Abby Wheelis Date: Tue, 19 Sep 2023 16:28:33 -0600 Subject: [PATCH] add some DiaryHelper tests 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) --- www/__tests__/diaryHelper.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/www/__tests__/diaryHelper.test.ts b/www/__tests__/diaryHelper.test.ts index 3aab018e1..fa2ae800e 100644 --- a/www/__tests__/diaryHelper.test.ts +++ b/www/__tests__/diaryHelper.test.ts @@ -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(); +}); \ No newline at end of file