Skip to content

Test/new/scheduler#126

Draft
trappaly wants to merge 5 commits intodevelopmentfrom
test/new/scheduler
Draft

Test/new/scheduler#126
trappaly wants to merge 5 commits intodevelopmentfrom
test/new/scheduler

Conversation

@trappaly
Copy link
Copy Markdown
Collaborator

No description provided.

@trappaly trappaly marked this pull request as ready for review May 13, 2025 21:44
@khanhdo05 khanhdo05 self-requested a review May 13, 2025 22:52
Copy link
Copy Markdown
Collaborator

@khanhdo05 khanhdo05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see each comments to learn and understand better testing.

Actions required

  • Fix indentation
  • Remove unnecessary tests like those that tested minuteNumberToHour, minuteNumberToMinute, minuteNumberToHourAndMinute
  • Move tests for dateToMinuteNumber and timeStringToMinuteNumber to backend/src/test/userPreferenceUtils.spec.ts, make sure to write corresponding describe blocks.

};
}


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaning up, good

const result = UserPreferenceUtils.dateToMinuteNumber(new Date('2025-08-20T05:05:00'));
expect(result).toBe(305);
});
});
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These blocks of 109 to 120 are indented weird, are they part of describe ("test date to minutes") ?, if so please indent them correctly.

* Tests converting a string to minutes : timeStringToMinuteNumber
*/
describe ("string to minute", () => {
// Tests for 0 edge case
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird identation, please fix

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this test file is unnecessary.

Naming notes

First of all, good naming habit for tests is that you test the whole file and you have that exact file you are testing's name then .spec. Example here is that you are testing things from UserPreferenceUtils, it should be UserPreferenceUtils.spec.ts for the test file name. If you look into the test/, you will see I already make this file and have 1 test in there where I test the function transform.

Why did I say this test file you created is semi-unnecessary

Function timeStringToMinuteNumber() uses all the above functions that you also tested - does it make sense to keep re-testing things?

A good rule about whether we should test things is that:

  • Don't test something you didn't code, for example:
  public static minuteNumberToHour(m: number): number {
    return Math.floor(m / 60);
  }

  public static minuteNumberToMinute(m: number): number {
    return m % 60;
  }

These two functions are just math, it is not a logic you introduced, no need to test whether Javascript math module works or not.

What should have been tested instead

  • Not have this file
  • Write more test in backend/src/test/userPreferenceUtils.spec.ts
  • If there's edge cases you can think of in these tests you write below, incorporate it so that your test of transform or timeStringToMinuteNumber covers it.
  • Generally, for readability, I am ok with not writing more transform test but more timeStringToMinuteNumber but we do also need more transform tests.

@trappaly trappaly marked this pull request as draft May 14, 2025 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants