forked from discourse/discourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mainly we are after emberjs/ember-test-helpers#1445 so the Ember 5 test suite doesn't fail on canary, but also took some code from emberjs/ember-test-helpers#1378 as needed to make the code make sense.
- Loading branch information
1 parent
c437b9f
commit 176ed43
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
app/assets/javascripts/patches/@ember+test-helpers+2.9.4.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
diff --git a/node_modules/@ember/test-helpers/addon-test-support/@ember/test-helpers/setup-rendering-context.js b/node_modules/@ember/test-helpers/addon-test-support/@ember/test-helpers/setup-rendering-context.js | ||
index 4079777..b3a3cc2 100644 | ||
--- a/node_modules/@ember/test-helpers/addon-test-support/@ember/test-helpers/setup-rendering-context.js | ||
+++ b/node_modules/@ember/test-helpers/addon-test-support/@ember/test-helpers/setup-rendering-context.js | ||
@@ -54,7 +54,7 @@ let templateId = 0; | ||
Renders the provided template and appends it to the DOM. | ||
|
||
@public | ||
- @param {Template|Component} templateOrComponent the component (or template) to render | ||
+ @param {Template|Component} templateFactoryOrComponent the component (or template) to render | ||
@param {RenderOptions} options options hash containing engine owner ({ owner: engineOwner }) | ||
@returns {Promise<void>} resolves when settled | ||
|
||
@@ -64,9 +64,9 @@ let templateId = 0; | ||
</caption> | ||
await render(hbs`<div class="container"></div>`); | ||
*/ | ||
-export function render(templateOrComponent, options) { | ||
+export function render(templateFactoryOrComponent, options) { | ||
let context = getContext(); | ||
- if (!templateOrComponent) { | ||
+ if (!templateFactoryOrComponent) { | ||
throw new Error('you must pass a template to `render()`'); | ||
} | ||
return Promise.resolve().then(() => runHooks('render', 'start')).then(() => { | ||
@@ -88,16 +88,12 @@ export function render(templateOrComponent, options) { | ||
if (macroCondition(dependencySatisfies('ember-source', '<3.24.0'))) { | ||
// Pre 3.24, we just don't support rendering components at all, so we error | ||
// if we find anything that isn't a template. | ||
- const isTemplate = '__id' in templateOrComponent && '__meta' in templateOrComponent || 'id' in templateOrComponent && 'meta' in templateOrComponent; | ||
+ const isTemplate = '__id' in templateFactoryOrComponent && '__meta' in templateFactoryOrComponent || 'id' in templateFactoryOrComponent && 'meta' in templateFactoryOrComponent; | ||
if (!isTemplate) { | ||
throw new Error(`Using \`render\` with something other than a pre-compiled template is not supported until Ember 3.24 (you are on ${Ember.VERSION}).`); | ||
} | ||
- templateId += 1; | ||
- let templateFullName = `template:-undertest-${templateId}`; | ||
- ownerToRenderFrom.register(templateFullName, templateOrComponent); | ||
- templateOrComponent = lookupTemplate(ownerToRenderFrom, templateFullName); | ||
} else { | ||
- if (isComponent(templateOrComponent, owner)) { | ||
+ if (isComponent(templateFactoryOrComponent, owner)) { | ||
// We use this to track when `render` is used with a component so that we can throw an | ||
// assertion if `this.{set,setProperty} is used in the same test | ||
ComponentRenderMap.set(context, true); | ||
@@ -105,18 +101,18 @@ export function render(templateOrComponent, options) { | ||
if (setCalls !== undefined) { | ||
assert(`You cannot call \`this.set\` or \`this.setProperties\` when passing a component to \`render\`, but they were called for the following properties:\n${setCalls.map(key => ` - ${key}`).join('\n')}`); | ||
} | ||
- let ProvidedComponent = ensureSafeComponent(templateOrComponent, context); | ||
context = { | ||
- ProvidedComponent | ||
+ ProvidedComponent: templateFactoryOrComponent, | ||
}; | ||
- templateOrComponent = INVOKE_PROVIDED_COMPONENT; | ||
- } else { | ||
- templateId += 1; | ||
- let templateFullName = `template:-undertest-${templateId}`; | ||
- ownerToRenderFrom.register(templateFullName, templateOrComponent); | ||
- templateOrComponent = lookupTemplate(ownerToRenderFrom, templateFullName); | ||
+ templateFactoryOrComponent = INVOKE_PROVIDED_COMPONENT; | ||
} | ||
} | ||
+ | ||
+ templateId += 1; | ||
+ let templateFullName = `template:-undertest-${templateId}`; | ||
+ ownerToRenderFrom.register(templateFullName, templateFactoryOrComponent); | ||
+ let template = lookupTemplate(ownerToRenderFrom, templateFullName); | ||
+ | ||
let outletState = { | ||
render: { | ||
owner, | ||
@@ -138,7 +134,7 @@ export function render(templateOrComponent, options) { | ||
name: 'index', | ||
controller: context, | ||
ViewClass: undefined, | ||
- template: templateOrComponent, | ||
+ template, | ||
outlets: {} | ||
}, | ||
outlets: {} |