Skip to content

Commit a4b90bf

Browse files
committed
test: add some missing css classes tests, refactor
1 parent 1a44a7c commit a4b90bf

File tree

77 files changed

+393
-53
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+393
-53
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('ChartjsComponent', () => {
4040
component = fixture.componentInstance;
4141
component.data = undefined;
4242
component.type = 'line';
43+
component.wrapper = true;
4344
});
4445

4546
it('chart should create', fakeAsync(() => {
@@ -83,4 +84,9 @@ describe('ChartjsComponent', () => {
8384
expect(component.chart?.config?.data.labels?.length).toBe(5);
8485
expect(component.chart?.config?.data.datasets[1]?.data.length).toBe(5);
8586
}));
87+
88+
it('should have css classes', () => {
89+
fixture.detectChanges();
90+
expect(fixture.nativeElement).toHaveClass('chart-wrapper');
91+
});
8692
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ describe('AccordionItemComponent', () => {
2525
it('should create', () => {
2626
expect(component).toBeTruthy();
2727
});
28+
29+
it('should have css classes', () => {
30+
expect(fixture.nativeElement).toHaveClass('accordion-item');
31+
});
2832
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('AccordionComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('accordion');
28+
});
2529
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ describe('AlertComponent', () => {
2323
it('should create', () => {
2424
expect(component).toBeTruthy();
2525
});
26+
27+
it('should have css classes', () => {
28+
expect(fixture.nativeElement).toHaveClass('alert');
29+
});
2630
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('AvatarComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('avatar');
28+
});
2529
});

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ describe('BadgeComponent', () => {
88

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

1616
beforeEach(() => {
@@ -22,4 +22,8 @@ describe('BadgeComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('badge');
28+
});
2529
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('BreadcrumbItemComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('breadcrumb-item');
28+
});
2529
});

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2-
import { RouterTestingModule } from '@angular/router/testing';
3-
import { Router } from '@angular/router';
2+
import { provideRouter, Router } from '@angular/router';
43

54
import { BreadcrumbRouterComponent } from './breadcrumb-router.component';
65
import { BreadcrumbRouterService } from './breadcrumb-router.service';
@@ -13,10 +12,9 @@ describe('BreadcrumbComponent', () => {
1312
beforeEach(waitForAsync(() => {
1413
TestBed.configureTestingModule({
1514
imports: [
16-
RouterTestingModule.withRoutes([]),
1715
BreadcrumbRouterComponent
1816
],
19-
providers: [BreadcrumbRouterService]
17+
providers: [BreadcrumbRouterService, provideRouter([])]
2018
}).compileComponents();
2119
}));
2220

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { TestBed } from '@angular/core/testing';
2-
import { RouterTestingModule } from '@angular/router/testing';
32

43
import { BreadcrumbRouterService } from './breadcrumb-router.service';
4+
import { provideRouter } from '@angular/router';
55

66
describe('AppBreadcrumbService', () => {
77
let service: BreadcrumbRouterService;
88

99
beforeEach(() => {
1010
TestBed.configureTestingModule({
11-
imports: [RouterTestingModule.withRoutes([])]
11+
providers: [provideRouter([])]
1212
});
1313
service = TestBed.inject(BreadcrumbRouterService);
1414
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('BreadcrumbComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('breadcrumb');
28+
});
2529
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('ButtonGroupComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('btn-group');
28+
});
2529
});

projects/coreui-angular/src/lib/button-group/button-toolbar/button-toolbar.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('ButtonToolbarComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('btn-toolbar');
28+
});
2529
});

projects/coreui-angular/src/lib/button/button-close.directive.spec.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@ import { By } from '@angular/platform-browser';
66
class MockElementRef extends ElementRef {}
77

88
@Component({
9-
template: '<button cButtonClose></button>'
9+
template: '<button cButtonClose></button>',
10+
standalone: true,
11+
imports: [ButtonCloseDirective]
1012
})
1113
class TestComponent {}
1214

1315
describe('ButtonCloseDirective', () => {
1416

1517
let component: TestComponent;
1618
let fixture: ComponentFixture<TestComponent>;
17-
let buttonEl: DebugElement;
19+
let elementRef: DebugElement;
1820

1921
beforeEach(() => {
2022
TestBed.configureTestingModule({
21-
declarations: [TestComponent],
22-
imports: [ButtonCloseDirective],
23+
imports: [TestComponent, ButtonCloseDirective],
2324
providers: [{ provide: ElementRef, useClass: MockElementRef }]
2425
});
2526

2627
fixture = TestBed.createComponent(TestComponent);
2728
component = fixture.componentInstance;
28-
buttonEl = fixture.debugElement.query(By.css('button'));
29+
elementRef = fixture.debugElement.query(By.directive(ButtonCloseDirective));
2930

3031
fixture.detectChanges(); // initial binding
3132
});
@@ -34,4 +35,9 @@ describe('ButtonCloseDirective', () => {
3435
const directive = new ButtonCloseDirective();
3536
expect(directive).toBeTruthy();
3637
});
38+
39+
it('should have css classes', () => {
40+
expect(elementRef.nativeElement).toHaveClass('btn');
41+
expect(elementRef.nativeElement).toHaveClass('btn-close');
42+
});
3743
});
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
import { ButtonDirective } from './button.directive';
22
import { ComponentFixture, TestBed } from '@angular/core/testing';
3-
import { ButtonCloseDirective } from './button-close.directive';
43
import { Component, DebugElement, ElementRef } from '@angular/core';
54
import { By } from '@angular/platform-browser';
65

76
class MockElementRef extends ElementRef {}
87

98
@Component({
10-
template: `
11-
<button cButton></button>`
9+
template: '<button cButton color="info" size="lg"></button>',
10+
standalone: true,
11+
imports: [ButtonDirective]
1212
})
1313
class TestComponent {}
1414

1515
describe('ButtonDirective', () => {
1616

1717
let component: TestComponent;
1818
let fixture: ComponentFixture<TestComponent>;
19-
let buttonEl: DebugElement;
19+
let elementRef: DebugElement;
2020

2121
beforeEach(() => {
2222
TestBed.configureTestingModule({
23-
declarations: [TestComponent],
24-
imports: [ButtonCloseDirective],
23+
imports: [TestComponent, ButtonDirective],
2524
providers: [{ provide: ElementRef, useClass: MockElementRef }]
2625
});
2726

2827
fixture = TestBed.createComponent(TestComponent);
2928
component = fixture.componentInstance;
30-
buttonEl = fixture.debugElement.query(By.css('button'));
29+
elementRef = fixture.debugElement.query(By.directive(ButtonDirective));
3130

3231
fixture.detectChanges(); // initial binding
3332
});
@@ -36,4 +35,11 @@ describe('ButtonDirective', () => {
3635
const directive = new ButtonDirective();
3736
expect(directive).toBeTruthy();
3837
});
38+
39+
it('should have css classes', () => {
40+
expect(elementRef.nativeElement).toHaveClass('btn');
41+
expect(elementRef.nativeElement).toHaveClass('btn-lg');
42+
expect(elementRef.nativeElement).toHaveClass('btn-info');
43+
});
44+
3945
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CalloutComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('callout');
28+
});
2529
});

projects/coreui-angular/src/lib/card/card-body.component.spec.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ describe('CardBodyComponent', () => {
88

99
beforeEach(waitForAsync(() => {
1010
TestBed.configureTestingModule({
11-
imports: [ CardBodyComponent ]
11+
imports: [CardBodyComponent]
1212
})
13-
.compileComponents();
13+
.compileComponents();
1414
}));
1515

1616
beforeEach(() => {
@@ -22,4 +22,8 @@ describe('CardBodyComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card-body');
28+
});
2529
});

projects/coreui-angular/src/lib/card/card-footer.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CardFooterComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card-footer');
28+
});
2529
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CardGroupComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card-group');
28+
});
2529
});

projects/coreui-angular/src/lib/card/card-header-actions.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CardHeaderActionsComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card-header-actions');
28+
});
2529
});

projects/coreui-angular/src/lib/card/card-header.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CardHeaderComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card-header');
28+
});
2529
});

projects/coreui-angular/src/lib/card/card-img-overlay/card-img-overlay.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CardImgOverlayComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card-img-overlay');
28+
});
2529
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CardComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('card');
28+
});
2529
});

projects/coreui-angular/src/lib/carousel/carousel-caption/carousel-caption.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ describe('CarouselCaptionComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css class"', () => {
27+
expect(fixture.nativeElement).toHaveClass('carousel-caption');
28+
});
2529
});

projects/coreui-angular/src/lib/carousel/carousel-control/carousel-control.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,8 @@ describe('CarouselControlComponent', () => {
2929
it('should create', () => {
3030
expect(component).toBeTruthy();
3131
});
32+
33+
it('should have css class="carousel-control-next"', () => {
34+
expect(fixture.nativeElement).toHaveClass('carousel-control-next');
35+
});
3236
});

projects/coreui-angular/src/lib/carousel/carousel-inner/carousel-inner.component.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,8 @@ describe('CarouselInnerComponent', () => {
3030
it('should create', () => {
3131
expect(component).toBeTruthy();
3232
});
33+
34+
it('should have css classes', () => {
35+
expect(fixture.nativeElement).toHaveClass('carousel-inner');
36+
});
3337
});

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

+4
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ describe('CarouselItemComponent', () => {
2626
it('should create', () => {
2727
expect(component).toBeTruthy();
2828
});
29+
30+
it('should have css classes', () => {
31+
expect(fixture.nativeElement).toHaveClass('carousel-item');
32+
});
2933
});

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

+5
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ describe('CarouselComponent', () => {
2222
it('should create', () => {
2323
expect(component).toBeTruthy();
2424
});
25+
26+
it('should have css classes', () => {
27+
expect(fixture.nativeElement).toHaveClass('carousel');
28+
expect(fixture.nativeElement).toHaveClass('slide');
29+
});
2530
});

0 commit comments

Comments
 (0)