-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some tests and fixed on isValidDate missed occurance
-TravisCI was failing also b/c I missed a commit in my last push
- Loading branch information
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@uiowa/date-range-picker", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"author": "Changhui Xu <[email protected]>", | ||
"contributors": [ | ||
"Jacob Feuerbach <[email protected]>" | ||
|
58 changes: 58 additions & 0 deletions
58
projects/uiowa/date-range-picker/src/lib/date-range.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,58 @@ | ||
import { DateRange } from './date-range'; | ||
|
||
describe('isValidDate() tests', () => { | ||
it('String as Date should be false', () => { | ||
const actual = DateRange.isValidDate('aaaaa'); | ||
expect(actual).toBe(false); | ||
}); | ||
it('null as Date should be false', () => { | ||
const actual = DateRange.isValidDate(null); | ||
expect(actual).toBe(false); | ||
}); | ||
it('empty as Date should be false', () => { | ||
const actual = DateRange.isValidDate(NaN); | ||
expect(actual).toBe(false); | ||
}); | ||
it('Some Date as Date should be true', () => { | ||
const actual = DateRange.isValidDate(new Date()); | ||
expect(actual).toBe(true); | ||
}); | ||
it('Some Defined Date as Date should be true', () => { | ||
const actual = DateRange.isValidDate(new Date(2018, 0, 1)); | ||
expect(actual).toBe(true); | ||
}); | ||
it('Some number as Date should be true', () => { | ||
const actual = DateRange.isValidDate(123); | ||
expect(actual).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('createDateRange() tests', () => { | ||
const date1 = new Date(2018, 0, 1); | ||
const date2 = new Date(2018, 0, 15); | ||
it('Create Date Range with null and null should return null and null', () => { | ||
const actual = DateRange.createDateRange(null, null); | ||
expect(actual.start).toBe(null); | ||
expect(actual.end).toBe(null); | ||
}); | ||
it('Create Date Range with string and string should return null and null', () => { | ||
const actual = DateRange.createDateRange('a', 'b'); | ||
expect(actual.start).toBe(null); | ||
expect(actual.end).toBe(null); | ||
}); | ||
it('Create Date Range with date and null should return date and null', () => { | ||
const actual = DateRange.createDateRange(date1, null); | ||
expect(actual.start).toEqual(date1); | ||
expect(actual.end).toBe(null); | ||
}); | ||
it('Create Date Range with null and date should return null and date', () => { | ||
const actual = DateRange.createDateRange(null, date1); | ||
expect(actual.start).toBe(null); | ||
expect(actual.end).toEqual(date1); | ||
}); | ||
it('Create Date Range with date and date should return date and date', () => { | ||
const actual = DateRange.createDateRange(date1, date2); | ||
expect(actual.start).toEqual(date1); | ||
expect(actual.end).toEqual(date2); | ||
}); | ||
}); |
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
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