Skip to content

refactor(forms): refactor common validators used in unit tests - #38020

Closed
benbraou wants to merge 1 commit into
angular:masterfrom
benbraou:issue37831
Closed

benbraou wants to merge 1 commit into
angular:masterfrom
benbraou:issue37831

Conversation

@benbraou

@benbraou benbraou commented Jul 12, 2020 •

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

asyncValidator is duplicated across multiple form test files.

Issue Number: N/A
#37831

What is the new behavior?

A util file is added to forms test package:

  • it exposes simpleAsyncValidator, asyncValidator and asyncValidatorReturningObservable validators
  • it refactors simpleAsyncValidator and asyncValidator to use common promise creation code
  • it exposes currentStateOf allowing to get the validation state of a list of AbstractControl

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove
pullapprove Bot requested a review from AndrewKushnir July 12, 2020 23:53
@AndrewKushnir AndrewKushnir added area: forms action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Jul 13, 2020
@ngbot ngbot Bot added this to the needsTriage milestone Jul 13, 2020

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for performing this refactoring @benbraou 👍

I've left a few comments, please have a look when you get a chance.

I think it'd also be great to add some light-weight docs (describing what the function does and what arguments are) for all exported functions in the util.ts file.

Thank you.

Comment thread packages/forms/test/util.ts Resolved
Comment thread packages/forms/test/util.ts Resolved
Comment thread packages/forms/test/util.ts Resolved
Comment thread packages/forms/test/util.ts Resolved
Comment thread packages/forms/test/util.ts Resolved
A util file is added to forms test package:
- it exposes simpleAsyncValidator, asyncValidator and asyncValidatorReturningObservable validators
- it refactors simpleAsyncValidator and asyncValidator to use common promise creation code
- it exposes currentStateOf allowing to get the validation state of a list of AbstractControl

Closes angular#37831
@benbraou

Copy link
Copy Markdown
Contributor Author

Thank you for the review @AndrewKushnir 🙏. I updated the PR accordingly

@AndrewKushnir AndrewKushnir left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the updates @benbraou, the changes look great 👍

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 22, 2020
@mhevery mhevery added target: major This PR is targeted for the next major release target: patch This PR is targeted for the next patch release and removed target: patch This PR is targeted for the next patch release target: major This PR is targeted for the next major release labels Jul 23, 2020
@mhevery mhevery closed this in 062b8d9 Jul 23, 2020
mhevery pushed a commit to mhevery/angular that referenced this pull request Jul 23, 2020
…ar#38020)

A util file is added to forms test package:
- it exposes simpleAsyncValidator, asyncValidator and asyncValidatorReturningObservable validators
- it refactors simpleAsyncValidator and asyncValidator to use common promise creation code
- it exposes currentStateOf allowing to get the validation state of a list of AbstractControl

Closes angular#37831

PR Close angular#38020
@benbraou
benbraou deleted the issue37831 branch July 24, 2020 19:37
Splaktar pushed a commit to angular-hispano/angular that referenced this pull request Aug 8, 2020
…ar#38020)

A util file is added to forms test package:
- it exposes simpleAsyncValidator, asyncValidator and asyncValidatorReturningObservable validators
- it refactors simpleAsyncValidator and asyncValidator to use common promise creation code
- it exposes currentStateOf allowing to get the validation state of a list of AbstractControl

Closes angular#37831

PR Close angular#38020
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Aug 24, 2020
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ar#38020)

A util file is added to forms test package:
- it exposes simpleAsyncValidator, asyncValidator and asyncValidatorReturningObservable validators
- it refactors simpleAsyncValidator and asyncValidator to use common promise creation code
- it exposes currentStateOf allowing to get the validation state of a list of AbstractControl

Closes angular#37831

PR Close angular#38020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: forms cla: yes target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants