Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds the remaining tools for migrating the tests in #561. Prior to this commit there was not a good way to unify the I-N-U-R test style and the matrix style testing done for components using
testComponent
. It also converts the Basic style tests as they are not currently part of the components matrix found in ember-components-test.js.Notable Changes
testComponent
was largely about providing configuration as a means of abstractly defining and testing components so that you could use the same configuration for each component kind, glimmer, curly, dynamic, and basic. While this worked it was pretty opaque to the person writing the test as you weren't sure about all the configuration that could be passed or the actual test assertions that were being ran on your behalf. Furthermore, the configuration mixed concerns about how the test should be ran and the expectations.This PR introduces a hybrid between the pure configuration based approach and I-N-U-R styles tests. It does this by changing the
test
decorator,this.render()
,module
and adding 2 new APIsthis.assertComponent()
andthis.registerComponent()
.@test
The
test
decorator was changed in #578 to allow for it to be used as a CallExpression to pass configuration to descriptor.test
can takesComponentTestMeta
:This decouples the runner config from the actual component under test as you would find in
testComponent
. This information is than applied to the method so thatmodule
understands what to do with the unit.module
module
was changed to take a flag to have themodule
do the matrix style testing and to look at different props on the test method. Prior to these changes we were using private APIs to accomplish the matrix styling testing that no longer exist in future versions of QUnit. To achieve the same outcome, we simply loop over the props placing the test into an array for each kind of component that the test applies to. Once we have built up the matrix we iterate through the test arrays creating a new nested module for each kind.this.render()
this.render
can now take astring
or aComponentBlueprint
:This should be very similar to the configuration that you could pass to
testComponent
. It should be noted that callingthis.render
with a blueprint will build the correct component invocation for the specific kind of component that is currently under test and also register that component.this.registerComponent(type: ComponentKind, name: string, layout: string)
This API allows you to register a specific kind of component and simply a proxy to the
Environment
's register methods.this.assertComponent(content: string, attrs: Object)
This API is used to assert that the element that was rendered has the expected content and if it has Emberish attributes like a
ember-view
class name and a unique ID. It's important to note that the Basic kind of components do not have these details and thus you can test them simply withthis.assertHTML
.Example Usage