DEV: Throw error if `renderInOutlet` component has no template (#24900)
This commit is contained in:
parent
057778b710
commit
f51f467030
|
@ -31,6 +31,11 @@ export function extraConnectorComponent(outletName, klass) {
|
||||||
if (!hasInternalComponentManager(klass)) {
|
if (!hasInternalComponentManager(klass)) {
|
||||||
throw new Error("klass is not an Ember component");
|
throw new Error("klass is not an Ember component");
|
||||||
}
|
}
|
||||||
|
if (!getComponentTemplate(klass)) {
|
||||||
|
throw new Error(
|
||||||
|
"connector component has no associated template. Ensure the template is colocated or authored with gjs."
|
||||||
|
);
|
||||||
|
}
|
||||||
if (outletName.includes("/")) {
|
if (outletName.includes("/")) {
|
||||||
throw new Error("invalid outlet name");
|
throw new Error("invalid outlet name");
|
||||||
}
|
}
|
||||||
|
|
|
@ -466,6 +466,22 @@ module(
|
||||||
await render(hbs`<PluginOutlet @name="test-name" />`);
|
await render(hbs`<PluginOutlet @name="test-name" />`);
|
||||||
assert.dom(".gjs-test").hasText("Hello world from gjs");
|
assert.dom(".gjs-test").hasText("Hello world from gjs");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("throws errors for invalid components", function (assert) {
|
||||||
|
assert.throws(() => {
|
||||||
|
extraConnectorComponent("test-name/blah", <template>
|
||||||
|
hello world
|
||||||
|
</template>);
|
||||||
|
}, /invalid outlet name/);
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
extraConnectorComponent("test-name", {});
|
||||||
|
}, /klass is not an Ember component/);
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
extraConnectorComponent("test-name", class extends Component {});
|
||||||
|
}, /connector component has no associated template/);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue