Add tests for updated functionality in date-selector and formatting

This commit is contained in:
leigh-mil
2019-09-24 13:08:29 -04:00
parent 32583feb99
commit e26edcd1bb
2 changed files with 41 additions and 9 deletions

View File

@@ -163,6 +163,20 @@ describe('DateSelector', () => {
component.year = new Date().getFullYear()
expect(component.isYearValid).toEqual(true)
})
it('returns true when year is between min and max years', () => {
component.year = new Date('2019-01-01').getFullYear()
component.mindate = new Date('2018-01-01')
component.maxdate = new Date('2019-12-31')
expect(component.isYearValid).toEqual(true)
})
it('returns false when year is outside of min and max years', () => {
component.year = new Date('2020-01-01').getFullYear()
component.mindate = new Date('2018-01-01')
component.maxdate = new Date('2019-01-01')
expect(component.isYearValid).toEqual(false)
})
})
describe('formattedDate', () => {
@@ -184,4 +198,20 @@ describe('DateSelector', () => {
expect(component.formattedDate).toEqual('01/22/1988')
})
})
describe('isDateComplete', () => {
it('returns true if all fields are completed', () => {
component.day = 22
component.month = 1
component.year = 1988
expect(component.isDateComplete).toEqual(true)
})
it('returns false if all fields are not completed', () => {
component.day = 22
component.month = 1
component.year = 19
expect(component.isDateComplete).toEqual(false)
})
})
})