Skip to content

Commit

Permalink
Components without selectors will have a default one assigned
Browse files Browse the repository at this point in the history
Should fix getsaf#105
  • Loading branch information
duck-nukem committed Apr 17, 2019
1 parent bf93246 commit 4b8d92e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/models/renderer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,28 @@ describe('Renderer', () => {
done();
}
});

describe('without a selector defined on the component', () => {
@Component({template: '<div>Without selector</div>'})
class TestComponentWithoutSelector {}

@NgModule({declarations: [TestComponentWithoutSelector]})
class NoSelectorModule {}

it('should be able to render without a template specified', async () => {
const testSetup = new TestSetup(
TestComponentWithoutSelector,
NoSelectorModule,
);
testSetup.dontMock.push(TestComponentWithoutSelector);
//tslint:disable-next-line:no-shadowed-variable
const renderer = new Renderer(testSetup);

const {element} = await renderer.render();

expect(element).toBeTruthy();
});
});
});

describe('whenStable', () => {
Expand Down
6 changes: 6 additions & 0 deletions lib/models/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ export class Renderer<TComponent> {
this._verifyComponentBindings(resolvedTestComponent, finalOptions.bind);
}

if (resolvedTestComponent.selector === undefined) {
const selector = 'shallow-proxy-host';
resolvedTestComponent.selector = selector;
TestBed.overrideComponent(this._setup.testComponent, {set: {selector}});
}

const ComponentClass = createContainer(
template || this._createTemplateString(resolvedTestComponent, finalOptions.bind),
finalOptions.bind
Expand Down

0 comments on commit 4b8d92e

Please sign in to comment.