refactor(ct-angular): fix mount

Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>
This commit is contained in:
Younes Jaaidi 2024-02-23 01:00:33 +01:00
parent 12ed2e761a
commit c27a034d8a
No known key found for this signature in database
GPG key ID: 3126C5717BDF3241

View file

@ -87,12 +87,12 @@ const __pwFixtureRegistry = new Map();
* @param {Component} component * @param {Component} component
*/ */
async function __pwRenderComponent(component) { async function __pwRenderComponent(component) {
const Component = await __pwResolveComponent(component); const componentClass = component.type;
if (!Component) if (!componentClass)
throw new Error(`Unregistered component: ${component.type}. Following components are registered: ${[...__pwRegistry.keys()]}`); throw new Error(`Unregistered component: ${componentClass}. Following components are registered: ${[...__pwRegistry.keys()]}`);
const componentMetadata = reflectComponentType(Component); const componentMetadata = reflectComponentType(componentClass);
if (!componentMetadata?.isStandalone) if (!componentMetadata?.isStandalone)
throw new Error('Only standalone components are supported'); throw new Error('Only standalone components are supported');
@ -102,7 +102,7 @@ async function __pwRenderComponent(component) {
})(class {}); })(class {});
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [Component], imports: [componentClass],
declarations: [WrapperComponent] declarations: [WrapperComponent]
}); });
@ -124,9 +124,10 @@ async function __pwRenderComponent(component) {
return fixture; return fixture;
} }
async function __pwResolveComponent(component) { // async function __pwResolveComponent(component) {
return await window.__pwRegistry.resolveImportRef(component.type); // // const component = await window.__pwRegistry.resolveImportRef(component.type);
} // return await
// }
/** /**
* @param {import('@angular/core/testing').ComponentFixture} fixture * @param {import('@angular/core/testing').ComponentFixture} fixture