Suggested by @palys-swm:
Also, this is a great function to have some tests.
https://phab.comm.dev/D4317#121940
Took like a minute. Not sure if it helps much, but it doesn't hurt?
Differential D4327
[lib] Write some tests for `text-utils:pluralize(...)` atul on Jun 22 2022, 11:33 AM. Authored by Tags None Referenced Files
Details Suggested by @palys-swm:
https://phab.comm.dev/D4317#121940 Took like a minute. Not sure if it helps much, but it doesn't hurt? Ran tests
Diff Detail
Event Timeline
Comment Actions Best for a separate diff, but wondering if there a good way we can:
Comment Actions
yarn workspace lib test is already included in the CI
Will look at adding unit tests to pre-commit hooks Comment Actions
Comment Actions Tests look good but there's some redundancy that can be removed.
Comment Actions
Yeah that's why I included them. The redundancy was intentional Comment Actions Oh, okay my bad! I only made those suggestions since if this is part of the CI build we want it to run as fast as possible so we should eliminate redundant tests. Comment Actions No worries, I think that for tests we should err on the side of covering more cases vs eliminating redundancy. As for CI build times, the cost of an additional unit test is orders of magnitude too small to make a difference Comment Actions Thanks for creating these tests! I think they can be improved by using describe / it. We would have a single test suite for text utils, then a separate ones for each function, and then a separate test for each case. Something like this: describe('Text utils", () => { describe('pluralize function', () => { it('should return a single word when a single word is given, () => { expect(pluralize(['a'])).toBe('a'); }; ... }; ... }; There are a couple of advantages:
On the other hand creating these would take more time, but it should be worth it if we plan to analyze test reports. What do you think? Comment Actions @palys-swm thanks for the suggestion, this looks a lot better and each test is "self-documenting" |