-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature/negative durations #5
Changes from 6 commits
49802c1
2c1adbc
fb97b00
9494d6a
e261315
196866c
232ce70
b930319
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,11 +59,47 @@ describe('DurationPickerComponent', () => { | |
expect(component.generate()).toBe('P9MT10M'); | ||
}); | ||
|
||
it('generate() should correctly generate the negative duration values', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test is failing for me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
set(component, 1, 2, 3, 4, 5, 6, 7, true); | ||
expect(component.generate()).toBe('-P1Y2M3W4DT5H6M7S'); | ||
|
||
set(component, '1', '2', '3', '4', '5', '6', '7', true); | ||
expect(component.generate()).toBe('-P1Y2M3W4DT5H6M7S'); | ||
|
||
set(component, 1, 0, 0, 0, 0, 0, 0, true); | ||
expect(component.generate()).toBe('-P1Y'); | ||
|
||
set(component, 0, 123, 0, 0, 0, 0, 0, true); | ||
expect(component.generate()).toBe('-P123M'); | ||
|
||
set(component, 0, 0, 3, 0, 0, 0, 0, true); | ||
expect(component.generate()).toBe('-P3W'); | ||
|
||
set(component, 0, 0, 0, 2, 0, 0, 0, true); | ||
expect(component.generate()).toBe('-P2D'); | ||
|
||
set(component, 0, 0, 0, 0, 5, 0, 0, true); | ||
expect(component.generate()).toBe('-PT5H'); | ||
|
||
set(component, 0, 0, 0, 0, 0, 9, 0, true); | ||
expect(component.generate()).toBe('-PT9M'); | ||
|
||
set(component, 0, 0, 0, 0, 0, 0, 10, true); | ||
expect(component.generate()).toBe('-PT10S'); | ||
|
||
set(component, 0, 9, 0, 0, 0, 10, 0, true); | ||
expect(component.generate()).toBe('-P9MT10M'); | ||
}); | ||
|
||
it('generate() should correctly set the zero value according to the configuration', () => { | ||
set(component, 0, 0, 0, 0, 0, 0, 0); | ||
|
||
expect(component.generate()).toBe('PT0S'); | ||
|
||
set(component, 0, 0, 0, 0, 0, 0, 0, true); | ||
|
||
expect(component.generate()).toBe('PT0S'); | ||
|
||
component.config.zeroValue = null; | ||
expect(component.generate()).toBe(null); | ||
|
||
|
@@ -90,6 +126,20 @@ describe('DurationPickerComponent', () => { | |
expect(component.hours).toBe(5); | ||
expect(component.minutes).toBe(6); | ||
expect(component.seconds).toBe(7); | ||
expect(component.negative).toBe(false); | ||
|
||
component.value = '-P1Y2M3W4DT5H6M7S'; | ||
|
||
component.parse(); | ||
|
||
expect(component.years).toBe(1); | ||
expect(component.months).toBe(2); | ||
expect(component.weeks).toBe(3); | ||
expect(component.days).toBe(4); | ||
expect(component.hours).toBe(5); | ||
expect(component.minutes).toBe(6); | ||
expect(component.seconds).toBe(7); | ||
expect(component.negative).toBe(true); | ||
}); | ||
|
||
it('parse() should do nothing if the value is null', () => { | ||
|
@@ -173,6 +223,7 @@ function set( | |
hours, | ||
minutes, | ||
seconds, | ||
negative = false | ||
) { | ||
component.years = years; | ||
component.months = months; | ||
|
@@ -181,4 +232,5 @@ function set( | |
component.hours = hours; | ||
component.minutes = minutes; | ||
component.seconds = seconds; | ||
component.negative = negative; | ||
} |
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.
why do we need this
<input>
?