-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a helper method to convert the DateType objects in a more type safe way. While we are getting them as numbers in the actual application, it's better to prepare for them being Date or String objects as well. Write a helper method to deal with all 3 types that DateType can be.
- Loading branch information
1 parent
085a408
commit 1ad06de
Showing
3 changed files
with
127 additions
and
39 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/app/views/components/timeline-view/timeline-util.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as Util from './timeline-util'; | ||
|
||
describe('Timeline Utilities', () => { | ||
describe('DateType To Number', () => { | ||
it('exists', () => { | ||
expect(Util.dateTypeToNumber).not.toBeUndefined(); | ||
}); | ||
it('will pass number values through', () => { | ||
expect(Util.dateTypeToNumber(0)).toBe(0); | ||
expect(Util.dateTypeToNumber(Math.PI)).toBe(Math.PI); | ||
expect(Util.dateTypeToNumber(NaN)).toBeNaN(); | ||
}); | ||
it('will convert dates to number values', () => { | ||
expect(Util.dateTypeToNumber(new Date(0))).toBe(0); | ||
expect(Util.dateTypeToNumber(new Date(123456789))).toBe(123456789); | ||
}); | ||
it('will convert strings to number values', () => { | ||
expect(Util.dateTypeToNumber('0')).toBe(0); | ||
expect(Util.dateTypeToNumber(Math.PI.toString())).toBe(Math.PI); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters