Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components without selectors will have a default one assigned #106

Merged
merged 2 commits into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions lib/models/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export class Renderer<TComponent> {
this._verifyComponentBindings(resolvedTestComponent, finalOptions.bind);
}

const ComponentClass = createContainer(
const ComponentClass = resolvedTestComponent.selector ? createContainer(
template || this._createTemplateString(resolvedTestComponent, finalOptions.bind),
finalOptions.bind
);
) : this._setup.testComponent;

// Components may have their own providers, If the test component does,
// we will mock them out here..
Expand Down