Skip to content

Commit 0dc1d15

Browse files
committed
test: add test-lib script & make it work
1 parent 5fcb50b commit 0dc1d15

File tree

6 files changed

+35
-11
lines changed

6 files changed

+35
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"build": "ng build",
2121
"build-lib": "ng build @coreui/angular --prod",
2222
"test": "ng test",
23+
"test-lib": "ng test @coreui/angular",
2324
"lint": "ng lint",
2425
"e2e": "ng e2e",
2526
"publish": "cd dist/@coreui/angular/ && npm publish",

projects/coreui/angular/src/lib/sidebar/app-sidebar-nav.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
12
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3+
import { RouterTestingModule } from '@angular/router/testing';
24

35
import { AppSidebarNavComponent } from './app-sidebar-nav.component';
46

@@ -8,9 +10,11 @@ describe('AppSidebarNavComponent', () => {
810

911
beforeEach(async(() => {
1012
TestBed.configureTestingModule({
11-
declarations: [ AppSidebarNavComponent ]
13+
declarations: [AppSidebarNavComponent],
14+
imports: [RouterTestingModule],
15+
schemas: [NO_ERRORS_SCHEMA],
1216
})
13-
.compileComponents();
17+
.compileComponents();
1418
}));
1519

1620
beforeEach(() => {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { SidebarNavHelper } from '../app-sidebar-nav.service';
12
import { AppSidebarNavItemClassPipe } from './app-sidebar-nav-item-class.pipe';
23

34
describe('SidebarNavItemClassPipe', () => {
45
it('create an instance', () => {
5-
const pipe = new AppSidebarNavItemClassPipe();
6+
const pipe = new AppSidebarNavItemClassPipe(new SidebarNavHelper());
67
expect(pipe).toBeTruthy();
78
});
89
});

projects/coreui/angular/src/lib/sidebar/app-sidebar-nav/app-sidebar-nav-label.component.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
12
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3+
import { SidebarNavHelper } from '../app-sidebar-nav.service';
4+
import { AppSidebarNavBadgePipe } from './app-sidebar-nav-badge.pipe';
35
import { AppSidebarNavLabelComponent } from './app-sidebar-nav-label.component';
46

57
describe('AppSidebarNavLabelComponent', () => {
@@ -8,14 +10,17 @@ describe('AppSidebarNavLabelComponent', () => {
810

911
beforeEach(async(() => {
1012
TestBed.configureTestingModule({
11-
declarations: [ AppSidebarNavLabelComponent ]
13+
declarations: [AppSidebarNavLabelComponent, AppSidebarNavBadgePipe],
14+
providers: [SidebarNavHelper],
15+
schemas: [NO_ERRORS_SCHEMA],
1216
})
13-
.compileComponents();
17+
.compileComponents();
1418
}));
1519

1620
beforeEach(() => {
1721
fixture = TestBed.createComponent(AppSidebarNavLabelComponent);
1822
component = fixture.componentInstance;
23+
component.item = {};
1924
fixture.detectChanges();
2025
});
2126

projects/coreui/angular/src/lib/sidebar/app-sidebar-nav/app-sidebar-nav-link.component.spec.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
12
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2-
3+
import { RouterTestingModule } from '@angular/router/testing';
4+
import { AppSidebarNavBadgePipe } from './app-sidebar-nav-badge.pipe';
35
import { AppSidebarNavLinkComponent } from './app-sidebar-nav-link.component';
6+
import { AppSidebarNavLinkPipe } from './app-sidebar-nav-link.pipe';
47

58
describe('AppSidebarNavLinkComponent', () => {
69
let component: AppSidebarNavLinkComponent;
710
let fixture: ComponentFixture<AppSidebarNavLinkComponent>;
811

912
beforeEach(async(() => {
1013
TestBed.configureTestingModule({
11-
declarations: [ AppSidebarNavLinkComponent ]
14+
declarations: [
15+
AppSidebarNavLinkComponent,
16+
AppSidebarNavLinkPipe,
17+
AppSidebarNavBadgePipe,
18+
],
19+
imports: [RouterTestingModule],
20+
schemas: [NO_ERRORS_SCHEMA],
1221
})
13-
.compileComponents();
22+
.compileComponents();
1423
}));
1524

1625
beforeEach(() => {
1726
fixture = TestBed.createComponent(AppSidebarNavLinkComponent);
1827
component = fixture.componentInstance;
28+
component.item = {
29+
url: '',
30+
};
1931
fixture.detectChanges();
2032
});
2133

projects/coreui/angular/src/lib/sidebar/app-sidebar-nav/app-sidebar-nav-title.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ describe('AppSidebarNavTitleComponent', () => {
88

99
beforeEach(async(() => {
1010
TestBed.configureTestingModule({
11-
declarations: [ AppSidebarNavTitleComponent ]
11+
declarations: [AppSidebarNavTitleComponent],
1212
})
13-
.compileComponents();
13+
.compileComponents();
1414
}));
1515

1616
beforeEach(() => {
1717
fixture = TestBed.createComponent(AppSidebarNavTitleComponent);
1818
component = fixture.componentInstance;
19+
component.item = {};
1920
fixture.detectChanges();
2021
});
2122

0 commit comments

Comments
 (0)