/
goods.component.spec.ts
42 lines (34 loc) · 1.29 KB
/
goods.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
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { GoodsComponent } from './goods.component';
import { GoodInfoComponent } from '../good-info/good-info.component';
import { GoodsListComponent } from '../goods-list/goods-list.component';
import { GoodsDataService } from '../services/goods-data.service';
describe('GoodsComponent', () => {
let component: GoodsComponent;
let fixture: ComponentFixture<GoodsComponent>;
let goodsDataService;
const goodsDataServiceStub = {
getGoods: () => {}
};
let spy;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ GoodsComponent, GoodInfoComponent, GoodsListComponent ],
providers: [ { provide: GoodsDataService, useValue: goodsDataServiceStub } ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(GoodsComponent);
// TwainService actually injected into the component
goodsDataService = fixture.debugElement.injector.get(GoodsDataService);
// Setup spy on the `getGoods` method
spy = spyOn(goodsDataService, 'getGoods')
.and.returnValue(Promise.resolve([]));
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});