forked from juristr/angular-testing-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic-styles.component.spec.ts
48 lines (40 loc) · 1.23 KB
/
dynamic-styles.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import { customMatchers, expect, NgMatchers } from '../utils/custom-matchers';
import { Component } from '@angular/core';
@Component({
selector: 'test',
template: `
<div [style.background-color]="color"></div>
`
})
class DynamicStylesComponent {
color = 'black';
}
describe('DynamicStylesComponent', () => {
let component: DynamicStylesComponent;
let fixture: ComponentFixture<DynamicStylesComponent>;
beforeEach(
async(() => {
jasmine.addMatchers(customMatchers);
TestBed.configureTestingModule({
declarations: [DynamicStylesComponent]
}).compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(DynamicStylesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should correctly set the background style', () => {
expect(fixture.debugElement.children[0].nativeElement).toHaveCssStyle({
'background-color': 'black'
});
});
});