-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.component.spec.ts
More file actions
52 lines (41 loc) · 1.39 KB
/
order.component.spec.ts
File metadata and controls
52 lines (41 loc) · 1.39 KB
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
49
50
51
52
// order.component.spec.ts
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { OrderComponent } from './order.component';
import { DebugElement } from '@angular/core';
describe('OrderComponent', () => {
let fixture: ComponentFixture<OrderComponent>;
let component: OrderComponent;
let debugElement: DebugElement;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [OrderComponent]
});
fixture = TestBed.createComponent(OrderComponent);
component = fixture.componentInstance;
debugElement = fixture.debugElement;
});
it('should create', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
describe('order null', () => {
it('should display empty template.', () => {
// Setting order to null
component.order = null;
// Triggering change detection
fixture.detectChanges();
// Checking template
expect(debugElement.nativeElement.textContent).toEqual('');
});
});
describe('order not null', () => {
it('should display order value formatted as number.', () => {
// Setting order to null
component.order = {date: '2000-01-01', product: 'product 1', value: 1000};
// Triggering change detection
fixture.detectChanges();
// Checking template
expect(debugElement.nativeElement.textContent).toEqual('1,000');
});
});
});