Skip to content

Commit

Permalink
Components without selectors will have a default one assigned (#106)
Browse files Browse the repository at this point in the history
* Components without selectors will have a default one assigned

Should fix #105

* Components can now only be wrapped in a container if they have a selector
Reverted a broader fix for the same issue
  • Loading branch information
duck-nukem authored and getsaf committed Apr 18, 2019
1 parent 06414ba commit 04005f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 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
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

0 comments on commit 04005f6

Please sign in to comment.