标签:eval navbar nts desc 异步 tst creates 语言 imp
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { XXXComponent} from './xxx.component';
import { Component, Input } from '@angular/core';
import { NavbarService } from '../../core/navbar/navbar.service';
import { of } from 'rxjs/observable/of';
import { ActivatedRoute } from '@angular/router';
import { Logger } from 'sinint-application-core-spa';
import { XXXService } from '../shared/xxx.service';
import { TimeframeService } from '../shared/timeframe.service';
import { XXX } from '../models/xxx.model';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
@Component({ selector: 'xxx-screenshot', template: '' })
class XXXScreenshotStubComponent {
@Input() initWithRootAtStart = false;
@Input() selectedXXX: string;
}
describe('XXXComponent', () => {
let component: XXXComponent;
let fixture: ComponentFixture<XXXComponent>;
const urlSegment = [{ path: '', parameters: [] }];
const route = { url: of(urlSegment), snapshot: '' };
beforeEach(async(() => {
const xxxService = jasmine.createSpyObj('XXXService', ['getChildrenXXX', 'getXXX']);
const timeframeService = jasmine.createSpyObj('TimeframeService', ['getSelectedtimeframe']);
const navbarService = jasmine.createSpyObj('NavbarService', ['canNavigateBack']);
const logger = jasmine.createSpyObj('Logger', ['error', 'info']);
timeframeService.getSelectedtimeframe.and.returnValue(of({ count: 24, unit: 'today', value: 'today' }));
TestBed.configureTestingModule({
imports: [InfiniteScrollModule],
declarations: [
XXXComponent
],
providers: [
{ provide: XXXService, useValue: xxxService },
{ provide: TimeframeService, useValue: timeframeService },
{ provide: NavbarService, useValue: navbarService },
{ provide: ActivatedRoute, useValue: route },
{ provide: Logger, useValue: logger }
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(XXXComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
标签:eval navbar nts desc 异步 tst creates 语言 imp
原文地址:https://www.cnblogs.com/wyp1988/p/11447249.html