Skip to content

Commit

Permalink
render accepts any object with a component manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreeman committed Dec 21, 2022
1 parent e3f1cb8 commit 421d2a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from './setup-context';
import { Promise } from './-utils';
import settled from './settled';
import { hbs, TemplateFactory } from 'ember-cli-htmlbars';
import { hbs } from 'ember-cli-htmlbars';
import getRootElement from './dom/get-root-element';
import { Owner } from './build-owner';
import getTestMetadata from './test-metadata';
Expand All @@ -21,14 +21,13 @@ import isComponent from './-internal/is-component';
import { macroCondition, dependencySatisfies } from '@embroider/macros';
import { ComponentRenderMap, SetUsage } from './setup-context';
import { ensureSafeComponent } from '@embroider/util';
import type { ComponentInstance } from '@glimmer/interfaces';

const OUTLET_TEMPLATE = hbs`{{outlet}}`;
const EMPTY_TEMPLATE = hbs``;
const INVOKE_PROVIDED_COMPONENT = hbs`<this.ProvidedComponent />`;

export interface RenderingTestContext extends TestContext {
render(template: TemplateFactory): Promise<void>;
render(template: object): Promise<void>;
clearRender(): Promise<void>;

element: Element | Document;
Expand Down Expand Up @@ -100,7 +99,7 @@ export interface RenderOptions {
await render(hbs`<div class="container"></div>`);
*/
export function render(
templateOrComponent: TemplateFactory | ComponentInstance,
templateOrComponent: object,
options?: RenderOptions
): Promise<void> {
let context = getContext();
Expand Down Expand Up @@ -298,7 +297,7 @@ export default function setupRenderingContext(
.then(() => {
let { owner } = context;

let renderDeprecationWrapper = function (template: TemplateFactory) {
let renderDeprecationWrapper = function (template: object) {
deprecate(
'Using this.render has been deprecated, consider using `render` imported from `@ember/test-helpers`.',
false,
Expand Down
5 changes: 1 addition & 4 deletions type-tests/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ expectTypeOf(currentURL).toEqualTypeOf<() => string>();

// Rendering Helpers
expectTypeOf(render).toMatchTypeOf<
(
templateOrComponent: TemplateFactory | ComponentInstance,
options?: { owner?: Owner }
) => Promise<void>
(templateOrComponent: object, options?: { owner?: Owner }) => Promise<void>
>();
expectTypeOf(clearRender).toEqualTypeOf<() => Promise<void>>();

Expand Down

0 comments on commit 421d2a0

Please sign in to comment.