Skip to content

Commit 79b21c3

Browse files
committed
test: add some missing tests and expectations, cleanup
1 parent 4fe3f2f commit 79b21c3

File tree

35 files changed

+235
-110
lines changed

35 files changed

+235
-110
lines changed

projects/coreui-angular/src/lib/accordion/accordion-item/accordion-item.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { AccordionItemComponent } from './accordion-item.component';
4+
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
5+
import { CollapseModule } from '../../collapse';
46
import { AccordionService } from '../accordion.service';
7+
import { AccordionButtonDirective } from '../accordion-button/accordion-button.directive';
58

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

1013
beforeEach(async () => {
1114
await TestBed.configureTestingModule({
12-
declarations: [ AccordionItemComponent ],
13-
providers: [AccordionService]
15+
declarations: [ AccordionItemComponent, AccordionButtonDirective ],
16+
providers: [AccordionService],
17+
imports: [NoopAnimationsModule, CollapseModule]
1418
})
1519
.compileComponents();
1620
});

projects/coreui-angular/src/lib/breadcrumb/breadcrumb-item/breadcrumb-item.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
2+
import { RouterTestingModule } from '@angular/router/testing';
3+
import { SharedModule } from '../../shared';
34
import { BreadcrumbItemComponent } from './breadcrumb-item.component';
45

56
describe('BreadcrumbItemComponent', () => {
@@ -8,9 +9,10 @@ describe('BreadcrumbItemComponent', () => {
89

910
beforeEach(async () => {
1011
await TestBed.configureTestingModule({
11-
declarations: [ BreadcrumbItemComponent ]
12+
declarations: [BreadcrumbItemComponent],
13+
imports: [SharedModule, RouterTestingModule]
1214
})
13-
.compileComponents();
15+
.compileComponents();
1416
});
1517

1618
beforeEach(() => {

projects/coreui-angular/src/lib/breadcrumb/breadcrumb-router/breadcrumb-router.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Router } from '@angular/router';
55

66
import { BreadcrumbRouterComponent } from './breadcrumb-router.component';
77
import { BreadcrumbRouterService } from './breadcrumb-router.service';
8+
import { BreadcrumbModule } from '../breadcrumb.module';
89

910
describe('BreadcrumbComponent', () => {
1011
let component: BreadcrumbRouterComponent;
@@ -13,9 +14,9 @@ describe('BreadcrumbComponent', () => {
1314

1415
beforeEach(waitForAsync(() => {
1516
TestBed.configureTestingModule({
16-
imports: [ CommonModule, RouterTestingModule.withRoutes([]) ],
17+
imports: [ CommonModule, RouterTestingModule.withRoutes([]), BreadcrumbModule ],
1718
declarations: [ BreadcrumbRouterComponent ],
18-
providers: [ BreadcrumbRouterService ]
19+
providers: [ BreadcrumbRouterService ],
1920
})
2021
.compileComponents();
2122
}));
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
import { ElementRef, Renderer2 } from '@angular/core';
2+
import { DropdownService } from '../dropdown.service';
13
import { DropdownItemDirective } from './dropdown-item.directive';
24

35
describe('DropdownItemDirective', () => {
4-
// it('should create an instance', () => {
5-
// const directive = new DropdownItemDirective();
6-
// expect(directive).toBeTruthy();
7-
// });
6+
let renderer: Renderer2;
7+
let hostElement: ElementRef;
8+
9+
it('should create an instance', () => {
10+
const dropdownService = new DropdownService();
11+
const directive = new DropdownItemDirective(renderer, hostElement, dropdownService);
12+
expect(directive).toBeTruthy();
13+
});
814
});
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import { ElementRef } from '@angular/core';
2+
import { DropdownService } from '../dropdown.service';
13
import { DropdownMenuDirective } from './dropdown-menu.directive';
24

35
describe('DropdownMenuDirective', () => {
4-
// it('should create an instance', () => {
5-
// const directive = new DropdownMenuDirective();
6-
// expect(directive).toBeTruthy();
7-
// });
6+
let elementRef: ElementRef;
7+
it('should create an instance', () => {
8+
const dropdownService = new DropdownService();
9+
const directive = new DropdownMenuDirective(elementRef, dropdownService);
10+
expect(directive).toBeTruthy();
11+
});
812
});

projects/coreui-angular/src/lib/dropdown/dropdown/dropdown.component.spec.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
33
import { DropdownComponent } from './dropdown.component';
44
import { CdkConnectedOverlay } from '@angular/cdk/overlay';
55
import { FocusOrigin } from '@angular/cdk/a11y';
6+
import { DropdownModule } from '../dropdown.module';
67

78
describe('DropdownComponent', () => {
8-
// let component: DropdownComponent;
9-
// let fixture: ComponentFixture<DropdownComponent>;
10-
//
11-
// beforeEach(async () => {
12-
// await TestBed.configureTestingModule({
13-
// declarations: [ DropdownComponent ]
14-
// })
15-
// .compileComponents();
16-
// });
17-
//
18-
// beforeEach(() => {
19-
// fixture = TestBed.createComponent(DropdownComponent);
20-
// component = fixture.componentInstance;
21-
// fixture.detectChanges();
22-
// });
23-
//
24-
// it('should create', () => {
25-
// expect(component).toBeTruthy();
26-
// });
9+
let component: DropdownComponent;
10+
let fixture: ComponentFixture<DropdownComponent>;
11+
12+
beforeEach(async () => {
13+
await TestBed.configureTestingModule({
14+
declarations: [ DropdownComponent ],
15+
imports: [DropdownModule]
16+
})
17+
.compileComponents();
18+
});
19+
20+
beforeEach(() => {
21+
fixture = TestBed.createComponent(DropdownComponent);
22+
component = fixture.componentInstance;
23+
fixture.detectChanges();
24+
});
25+
26+
it('should create', () => {
27+
expect(component).toBeTruthy();
28+
});
2729
});

projects/coreui-angular/src/lib/form/form-check/form-check.component.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,20 @@ describe('FormCheckComponent', () => {
1010

1111
beforeEach(waitForAsync(() => {
1212
TestBed.configureTestingModule({
13-
declarations: [ FormCheckComponent ],
13+
declarations: [FormCheckComponent],
1414
providers: [Renderer2]
1515
})
16-
.compileComponents();
16+
.compileComponents();
1717
}));
1818

19-
20-
// todo
2119
beforeEach(() => {
22-
// fixture = TestBed.createComponent(FormCheckComponent);
23-
// renderer = fixture.debugElement.injector.get(Renderer2);
24-
// component = fixture.componentInstance;
25-
// fixture.detectChanges();
20+
fixture = TestBed.createComponent(FormCheckComponent);
21+
renderer = fixture.debugElement.injector.get(Renderer2);
22+
component = fixture.componentInstance;
23+
fixture.detectChanges();
2624
});
2725

2826
it('should create', () => {
29-
// expect(component).toBeTruthy();
27+
expect(component).toBeTruthy();
3028
});
3129
});
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { ElementRef } from '@angular/core';
12
import { FormControlDirective } from './form-control.directive';
23

34
describe('FormControlDirective', () => {
5+
let hostElement: ElementRef;
46
it('should create an instance', () => {
5-
// const directive = new FormControlDirective();
6-
// expect(directive).toBeTruthy();
7+
const directive = new FormControlDirective(hostElement);
8+
expect(directive).toBeTruthy();
79
});
810
});
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
import { TestBed } from '@angular/core/testing';
2+
import { ElementRef, Renderer2 } from '@angular/core';
3+
14
import { HeaderTogglerDirective } from './header-toggler.directive';
25

36
describe('HeaderTogglerDirective', () => {
7+
let renderer: Renderer2;
8+
let hostElement: ElementRef;
9+
10+
beforeEach(() => {
11+
TestBed.configureTestingModule({
12+
imports: [Renderer2],
13+
providers: [Renderer2]
14+
});
15+
});
16+
417
it('should create an instance', () => {
5-
// todo
6-
// const directive = new HeaderTogglerDirective();
7-
// expect(directive).toBeTruthy();
18+
const directive = new HeaderTogglerDirective(renderer, hostElement);
19+
expect(directive).toBeTruthy();
820
});
921
});

projects/coreui-angular/src/lib/modal/modal-dismiss/modal-dismiss.directive.spec.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ModalToggleDirective } from './modal-toggle.directive';
2+
import { ModalService } from '../modal.service';
3+
4+
describe('ModalDismissDirective', () => {
5+
it('should create an instance', () => {
6+
const modalService = new ModalService()
7+
const directive = new ModalToggleDirective(modalService);
8+
expect(directive).toBeTruthy();
9+
});
10+
});

projects/coreui-angular/src/lib/modal/modal/modal.component.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
33

44
import { ModalComponent } from './modal.component';
5+
import { ModalModule } from '../modal.module';
56

67
describe('ModalComponent', () => {
78
let component: ModalComponent;
89
let fixture: ComponentFixture<ModalComponent>;
910

1011
beforeEach(async () => {
1112
await TestBed.configureTestingModule({
12-
imports: [ NoopAnimationsModule ],
13-
declarations: [ ModalComponent ]
13+
imports: [ NoopAnimationsModule, ModalModule ],
14+
declarations: [ ModalComponent ],
1415
})
1516
.compileComponents();
1617
});
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { NavbarTogglerDirective } from './navbar-toggler.directive';
2+
import { ElementRef, Renderer2 } from '@angular/core';
23

34
describe('NavbarTogglerDirective', () => {
5+
let renderer: Renderer2;
6+
let hostElement: ElementRef;
7+
48
it('should create an instance', () => {
5-
// const directive = new NavbarTogglerDirective();
6-
// expect(directive).toBeTruthy();
9+
const directive = new NavbarTogglerDirective(renderer, hostElement);
10+
expect(directive).toBeTruthy();
711
});
812
});

projects/coreui-angular/src/lib/pagination/page-item/page-item.component.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@ describe('PaginationItemComponent', () => {
88

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

16-
// todo
1716
beforeEach(() => {
18-
// fixture = TestBed.createComponent(PageItemComponent);
19-
// component = fixture.componentInstance;
20-
// fixture.detectChanges();
17+
fixture = TestBed.createComponent(PageItemComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
2120
});
2221

2322
it('should create', () => {
24-
// expect(component).toBeTruthy();
23+
expect(component).toBeTruthy();
2524
});
2625
});
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { PageItemDirective } from './page-item.directive';
2+
import { TestBed } from '@angular/core/testing';
3+
import { Renderer2 } from '@angular/core';
24

35
describe('PageItemDirective', () => {
6+
let renderer: Renderer2;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({
10+
imports: [Renderer2],
11+
providers: [Renderer2]
12+
});
13+
});
414
it('should create an instance', () => {
5-
// const directive = new PageItemDirective();
6-
// expect(directive).toBeTruthy();
15+
const directive = new PageItemDirective(renderer);
16+
expect(directive).toBeTruthy();
717
});
818
});
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import { ComponentFactoryResolver, ElementRef, Renderer2, ViewContainerRef } from '@angular/core';
2+
import { ListenersService } from '../services/listeners.service';
13
import { PopoverDirective } from './popover.directive';
24

35
describe('PopoverDirective', () => {
4-
// it('should create an instance', () => {
5-
// const directive = new PopoverDirective();
6-
// expect(directive).toBeTruthy();
7-
// });
6+
let document: Document;
7+
let renderer: Renderer2;
8+
let hostElement: ElementRef;
9+
let componentFactoryResolver: ComponentFactoryResolver;
10+
let viewContainerRef: ViewContainerRef;
11+
12+
it('should create an instance', () => {
13+
const listenersService = new ListenersService(renderer);
14+
const directive = new PopoverDirective(document, renderer, hostElement, componentFactoryResolver, viewContainerRef, listenersService);
15+
expect(directive).toBeTruthy();
16+
});
817
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SidebarNavLinkComponent } from './sidebar-nav-link.component';
99
import { SidebarNavTitleComponent } from './sidebar-nav-title.component';
1010
import { SidebarNavIconPipe } from './sidebar-nav-icon.pipe';
1111
import { HtmlAttributesDirective } from '../../shared';
12+
import { SidebarModule } from '../sidebar.module';
1213

1314
describe('SidebarNavGroupComponent', () => {
1415
let component: SidebarNavGroupComponent;
@@ -18,15 +19,15 @@ describe('SidebarNavGroupComponent', () => {
1819

1920
beforeEach(waitForAsync(() => {
2021
TestBed.configureTestingModule({
21-
imports: [ RouterTestingModule.withRoutes([]) ],
22+
imports: [ RouterTestingModule.withRoutes([]), SidebarModule ],
2223
declarations: [
2324
SidebarNavDividerComponent,
2425
SidebarNavGroupComponent,
2526
SidebarNavLabelComponent,
2627
SidebarNavLinkComponent,
2728
SidebarNavTitleComponent,
2829
HtmlAttributesDirective,
29-
SidebarNavIconPipe
30+
SidebarNavIconPipe,
3031
],
3132
})
3233
.compileComponents();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
22

33
import {SidebarNavLabelComponent} from './sidebar-nav-label.component';
44
import {SidebarNavHelper} from './sidebar-nav.service';
5+
import { SharedModule } from '../../shared';
56
// import {LayoutModule} from '../../shared/layout/index.ts_';
67

78
describe('SidebarNavLabelComponent', () => {
@@ -13,7 +14,7 @@ describe('SidebarNavLabelComponent', () => {
1314
TestBed.configureTestingModule({
1415
declarations: [ SidebarNavLabelComponent ],
1516
providers: [ SidebarNavHelper ],
16-
// imports: [ LayoutModule ],
17+
imports: [ SharedModule ],
1718
})
1819
.compileComponents();
1920
}));

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SidebarNavLinkPipe } from './sidebar-nav-link.pipe';
77
import { SidebarNavBadgePipe } from './sidebar-nav-badge.pipe';
88
import { SidebarNavIconPipe } from './sidebar-nav-icon.pipe';
99
import { HtmlAttributesDirective } from '../../shared';
10+
import { SidebarModule } from '../sidebar.module';
1011

1112
describe('SidebarNavLinkComponent', () => {
1213
let component: SidebarNavLinkComponent;
@@ -16,7 +17,7 @@ describe('SidebarNavLinkComponent', () => {
1617

1718
beforeEach(waitForAsync(() => {
1819
TestBed.configureTestingModule({
19-
imports: [RouterTestingModule.withRoutes([])],
20+
imports: [RouterTestingModule.withRoutes([]), SidebarModule],
2021
declarations: [SidebarNavLinkComponent, HtmlAttributesDirective, SidebarNavLinkPipe, SidebarNavBadgePipe, SidebarNavIconPipe]
2122
})
2223
.compileComponents();

0 commit comments

Comments
 (0)