Skip to content

Commit 45f9dc5

Browse files
committed
test(bg-color): css classes coverage
1 parent 5f16004 commit 45f9dc5

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1-
import { TestBed } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
22
import { BgColorDirective } from './bg-color.directive';
3+
import { Component, DebugElement } from '@angular/core';
4+
import { By } from '@angular/platform-browser';
5+
6+
@Component({
7+
imports: [BgColorDirective],
8+
template: '<div cBgColor="primary"></div>'
9+
})
10+
class TestComponent {}
311

412
describe('BgColorDirective', () => {
13+
let component: TestComponent;
14+
let fixture: ComponentFixture<TestComponent>;
15+
let debugElement: DebugElement;
16+
17+
beforeEach(() => {
18+
TestBed.configureTestingModule({
19+
imports: [TestComponent]
20+
}).compileComponents();
21+
22+
fixture = TestBed.createComponent(TestComponent);
23+
component = fixture.componentInstance;
24+
debugElement = fixture.debugElement.query(By.directive(BgColorDirective));
25+
fixture.detectChanges();
26+
});
27+
528
it('should create an instance', () => {
629
TestBed.runInInjectionContext(() => {
7-
const directive = new BgColorDirective();
8-
expect(directive).toBeTruthy();
30+
const directive = new BgColorDirective();
31+
expect(directive).toBeTruthy();
932
});
1033
});
34+
35+
it('should have css classes', () => {
36+
expect(debugElement.nativeElement).toHaveClass('bg-primary');
37+
});
1138
});

0 commit comments

Comments
 (0)