Skip to content

Commit

Permalink
fix(e2e): test theme service append to layout top by factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Tibing committed Feb 20, 2018
1 parent 216139e commit 0c721ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
22 changes: 21 additions & 1 deletion e2e/layout-dynamic.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('nb-layout theme', () => {
});
});

it('should insert append into nb-layout', () => {
it('should append into nb-layout', () => {

const button = element(by.css('#add-dynamic'));

Expand All @@ -38,6 +38,26 @@ describe('nb-layout theme', () => {
});
});

it('should append by factory into nb-layout', () => {

const button = element(by.css('#add-dynamic-by-factory'));

button.click().then(() => {
return browser.driver.wait(() => {
return element(by.css('nb-layout')).$$('*').first().getTagName().then(value => {
return value === 'nb-dynamic-to-add';
});
}, 10000);
});

element(by.css('nb-layout')).$$('*').first().getTagName().then(value => {
expect(value).toMatch('nb-dynamic-to-add');
});
element(by.css('nb-layout')).$$('*').get(1).getTagName().then(value => {
expect(value).toMatch('div');
});
});

it('should clear dymamic nb-layout area', () => {

const buttonAdd = element(by.css('#add-dynamic'));
Expand Down
10 changes: 8 additions & 2 deletions src/app/layout-test/theme-dynamic-test.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { Component } from '@angular/core';
import { Component, ComponentFactoryResolver } from '@angular/core';

import { NbThemeService } from '@nebular/theme';

Expand All @@ -25,6 +25,7 @@ export class NbDynamicToAddComponent {}
<nb-layout-header fixed>
<a href="#" class="navbar-brand">Akveo</a>
<button id="add-dynamic" (click)="addDynamicComponent()">Add Dynamic Copmonent</button>
<button id="add-dynamic-by-factory" (click)="addDynamicByFactory()">Add Dynamic By Factory</button>
<button id="clear-dynamic" (click)="clearDynamicComponents()">Clear Dynamic Copmonents</button>
</nb-layout-header>
Expand All @@ -49,12 +50,17 @@ export class NbDynamicToAddComponent {}
`,
})
export class NbThemeDynamicTestComponent {
constructor(private themeService: NbThemeService) {}
constructor(private themeService: NbThemeService, private componentFactoryResolver: ComponentFactoryResolver) {}

addDynamicComponent() {
this.themeService.appendToLayoutTop(NbDynamicToAddComponent).subscribe(cRef => console.info(cRef));
}

addDynamicByFactory() {
const factory = this.componentFactoryResolver.resolveComponentFactory(NbDynamicToAddComponent);
this.themeService.appendToLayoutTop(factory).subscribe(cRef => console.info(cRef));
}

clearDynamicComponents() {
this.themeService.clearLayoutTop().subscribe(res => console.info(res));
}
Expand Down

0 comments on commit 0c721ee

Please sign in to comment.