Skip to content
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(timepicker): setting hour/minute/second step to undefined #2903

Conversation

avsorokin
Copy link
Contributor

Closes #2851

Also added some tests for step setting via component input properties

@maxokorokov maxokorokov added this to the 4.0.1 milestone Dec 13, 2018
Copy link
Member

@maxokorokov maxokorokov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR!

Left a couple of comments.

@@ -96,6 +96,10 @@ export class NgbTimepicker implements ControlValueAccessor,
disabled: boolean;
model: NgbTime;

private _hourStep;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add : number type

@@ -136,7 +159,7 @@ export class NgbTimepicker implements ControlValueAccessor,
*/
@Input() size: 'small' | 'medium' | 'large';

constructor(config: NgbTimepickerConfig, private _ngbTimeAdapter: NgbTimeAdapter<any>) {
constructor(private readonly config: NgbTimepickerConfig, private _ngbTimeAdapter: NgbTimeAdapter<any>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As config becomes private, please rename to _config (see https://github.com/ng-bootstrap/ng-bootstrap/wiki/Contributions%3A-Code-conventions)

});
}));

it('should increment / decrement minutes by 7', async(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please simplify tests, as we should use async/await or fakeAsync (I know you were inspired by already exsiting ones, but now there is a shorter way to write) →

Before:

it('should increment / decrement minutes by 7', async(() => {
  //...
  fixture.detectChanges();
  fixture.whenStable()
    .then(() => {
      fixture.detectChanges();
      return fixture.whenStable();
    })
    .then(() => {
      // ...
    });
}));

After:

it('should increment / decrement minutes by 7', async(async () => {
  // ...
  fixture.detectChanges();
  await fixture.whenStable();
  fixture.detectChanges();
  // ...
}));

@@ -114,17 +118,36 @@ export class NgbTimepicker implements ControlValueAccessor,
/**
* Number of hours to increase or decrease when using a button.
*/
@Input() hourStep: number;
@Input() set hourStep(step: number) {
this._hourStep = isNumber(step) ? step : this.config.hourStep;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better isInteger() ?

@maxokorokov
Copy link
Member

Oh, also the build failed because of improper code formatting: https://travis-ci.org/ng-bootstrap/ng-bootstrap/builds/463821660#L508

You could run yarn ci locally to run all things Traivs CI does ot just yarn check-format to check formatting. More details here: https://github.com/ng-bootstrap/ng-bootstrap/blob/master/DEVELOPER.md#useful-commands. Thanks for contributing!

@maxokorokov maxokorokov modified the milestones: 4.0.1, 4.0.2 Dec 13, 2018
@avsorokin
Copy link
Contributor Author

Thanks for the comments! I've updated the PR.

@codecov-io
Copy link

Codecov Report

Merging #2903 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2903      +/-   ##
==========================================
+ Coverage   91.16%   91.23%   +0.06%     
==========================================
  Files          89       89              
  Lines        2863     2885      +22     
  Branches      466      475       +9     
==========================================
+ Hits         2610     2632      +22     
  Misses        181      181              
  Partials       72       72
Impacted Files Coverage Δ
src/timepicker/timepicker.ts 98.78% <100%> (+0.09%) ⬆️
src/util/util.ts 100% <0%> (ø) ⬆️
src/carousel/carousel.ts 98.68% <0%> (+0.03%) ⬆️
src/datepicker/datepicker-service.ts 97.69% <0%> (+0.03%) ⬆️
src/datepicker/datepicker.ts 98.92% <0%> (+0.08%) ⬆️
src/typeahead/typeahead.ts 96% <0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74b9835...7110661. Read the comment docs.

Copy link
Member

@maxokorokov maxokorokov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@maxokorokov maxokorokov merged commit 34baece into ng-bootstrap:master Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants