-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add type to test code #2702
fix: add type to test code #2702
Conversation
miettal
commented
Jul 5, 2024
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files@@ Coverage Diff @@
## develop #2702 +/- ##
=============================================
+ Coverage 56.03% 56.04% +0.02%
- Complexity 8041 8044 +3
=============================================
Files 2059 2059
Lines 87513 87511 -2
Branches 6418 6420 +2
=============================================
+ Hits 49032 49041 +9
+ Misses 36797 36786 -11
Partials 1684 1684 |
@@ -37,7 +37,7 @@ describe('DateUtils', () => { | |||
}); | |||
|
|||
it('#isDateBefore - checks if given date is before date to be compared to', () => { | |||
const date: Date = DateUtils.stringToDate('2023-01-01'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input is gived by immediate value. so this code guarantee type is Date.
@@ -23,7 +23,7 @@ export namespace ArrayUtils { | |||
* @param arr the arr | |||
* @returns a number if arr not empty, else null | |||
*/ | |||
export function findBiggestNumber(arr: number[]): number | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test pattern has null and undefined. so this function work with null and undefined.
@@ -207,7 +207,7 @@ export namespace OeChartTester { | |||
export type Data = { | |||
type: 'data', | |||
label: string | Converter, | |||
value: number[] | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test data inlucde null element.
@@ -37,7 +37,7 @@ describe('DateUtils', () => { | |||
}); | |||
|
|||
it('#isDateBefore - checks if given date is before date to be compared to', () => { | |||
const date: Date = DateUtils.stringToDate('2023-01-01'); | |||
const date: Date = DateUtils.stringToDate('2023-01-01') as Date; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works. lines below it also follows similar pattern. a slight modification like below can solve 5 other strict errors.
isDateBefore(date: Date, compareDate: Date) -> isDateBefore(date: Date | null, compareDate: Date | null).
But it's upto you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. thank you for your feedback. This time I want to focus just adding types, So I will keep this line. But I will memorize this information in mind.
e78f7c3
to
8414d12
Compare
8414d12
to
24405e8
Compare
rebased! |
If I run:
I get
|
cb96c9f
to
fd22507
Compare
fd22507
to
e228a20
Compare
Sorry, I mis-rebased. now its ok. findSmallestNumber and findBiggestNumber was refactord. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 👍