Skip to content

Refactor the shared conditionals test cases#13047

Merged
chancancode merged 1 commit intomasterfrom
refactor-conditionals-tests
Mar 3, 2016
Merged

Refactor the shared conditionals test cases#13047
chancancode merged 1 commit intomasterfrom
refactor-conditionals-tests

Conversation

@chancancode
Copy link
Member

  • Extract the apply “generators” logic into a more generic function which allows us to pre-mix the BASIC_*_TESTS into a super class, instead of having to repeat that every time you call moduleFor.
  • Extend the “generators” concept to a more generic (very basic) mixin system, which allows us to separate the test cases into groups.
  • Instead of hard coding true and false inside the test cases, go through a getter that can be overridden by the subclasses.
  • Restructure the conditionals test classes to achieve better layering.
  • Test {{#if}}/{{#unless}} without inverse as a “matrix item” instead of a single test case which should give us better coverage. (The trick is to generate them as a pair in templateFor.)

Most of these work is to make it possible to reuse the basic test cases for {{#each}} tests, which will come in a different PR. This is needed because {{#each}} has different rules about truthiness than the “toggling” conditional constructs.

/cc @GavinJoyce @chadhietala @rwjblue

Copy link
Member Author

Choose a reason for hiding this comment

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

@GavinJoyce I finally cracked the nut on how to test "without inverse" as part of the bigger test suite! The trick is to generate the if/unless as a pair, both without inverses. I think you can probably use this trick for the helpers too once you have implemented inline-unless.

Copy link
Member

Choose a reason for hiding this comment

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

oh, nice one.

@wycats wycats force-pushed the refactor-conditionals-tests branch from 1078159 to 4a3536b Compare March 3, 2016 21:54
Copy link
Member Author

Choose a reason for hiding this comment

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

As per our usual protocol, we are supposed to be testing "update via mutation" and "reset via replacement" here.

@wycats wycats force-pushed the refactor-conditionals-tests branch 2 times, most recently from ed573c3 to 8acd705 Compare March 3, 2016 21:58
* Extract the apply “generators” logic into a more generic function
  which allows us to pre-mix the BASIC_*_TESTS into a super class,
  instead of having to repeat that every time you call `moduleFor`.

* Extend the “generators” concept to a more generic (very basic) mixin
  system, which allows us to separate the test cases into groups.

* Instead of hard coding `true` and `false` inside the test cases, go
  through a getter that can be overridden by the subclasses.

* Restructure the conditionals test classes to achieve better layering.

* Test `{{#if}}/{{#unless}}` without inverse as a “matrix item” instead
  of a single test case which should give us better coverage. (The trick
  is to generate them as a pair in `templateFor`.)

Most of these work is to make it possible to reuse the basic test cases
for `{{#each}}` tests, which will come in a different PR. This is needed
because `{{#each}}` has different rules about truthiness than the
“toggling” conditional constructs.
@wycats wycats force-pushed the refactor-conditionals-tests branch from 8acd705 to 84ac9b3 Compare March 3, 2016 22:03
chancancode added a commit that referenced this pull request Mar 3, 2016
Refactor the shared conditionals test cases
@chancancode chancancode merged commit 8b643c6 into master Mar 3, 2016
@chancancode chancancode deleted the refactor-conditionals-tests branch March 3, 2016 22:31
@homu homu mentioned this pull request Mar 3, 2016
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants