|
1 |
| -import { TestBed } from '@angular/core/testing'; |
| 1 | +import { ComponentFixture, TestBed } from '@angular/core/testing'; |
| 2 | +import { Component, DebugElement } from '@angular/core'; |
| 3 | +import { By } from '@angular/platform-browser'; |
2 | 4 | import { TextBgColorDirective } from './text-bg-color.directive';
|
3 | 5 |
|
| 6 | +@Component({ |
| 7 | + imports: [TextBgColorDirective], |
| 8 | + template: '<div cTextBgColor="primary"></div>' |
| 9 | +}) |
| 10 | +class TestComponent {} |
| 11 | + |
4 | 12 | describe('TextBgColorDirective', () => {
|
| 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(TextBgColorDirective)); |
| 25 | + fixture.detectChanges(); |
| 26 | + }); |
| 27 | + |
5 | 28 | it('should create an instance', () => {
|
6 | 29 | TestBed.runInInjectionContext(() => {
|
7 | 30 | const directive = new TextBgColorDirective();
|
8 | 31 | expect(directive).toBeTruthy();
|
9 | 32 | });
|
10 | 33 | });
|
| 34 | + |
| 35 | + it('should have css classes', () => { |
| 36 | + expect(debugElement.nativeElement).toHaveClass('text-bg-primary'); |
| 37 | + }); |
11 | 38 | });
|
0 commit comments