本文整理汇总了TypeScript中@integration/app.component.AppComponent类的典型用法代码示例。如果您正苦于以下问题:TypeScript component.AppComponent类的具体用法?TypeScript component.AppComponent怎么用?TypeScript component.AppComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了component.AppComponent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('AppComponent', () => {
let fixture: ComponentFixture<AppComponent>;
let component: AppComponent;
const initialState = {
todos: {
todo: [],
pizza: { model: undefined }
}
};
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppModule, RouterTestingModule, FormsModule, ReactiveFormsModule],
providers: [{ provide: ComponentFixtureAutoDetect, useValue: true }]
});
fixture = TestBed.createComponent(AppComponent);
component = fixture.componentInstance;
// reset store because of storage plugin
const store = TestBed.get(Store);
store.reset(initialState);
});
it('should add a todo', () => {
component.addTodo('Get Milk');
component.addTodo('Clean Bathroom');
component.todos$.subscribe((state: Todo[]) => {
expect(state.length).toBe(2);
});
});
it('should remove a todo', () => {
component.addTodo('Get Milk');
component.addTodo('Clean Bathroom');
component.removeTodo(1);
component.todos$.subscribe((state: Todo[]) => {
expect(state.length).toBe(1);
expect(state[0]).toBe('Get Milk');
});
});
it('should set toppings using form control', fakeAsync(() => {
component.pizzaForm.patchValue({ toppings: 'oli' });
tick(200);
let flag = false;
component.pizza$.pipe(take(1)).subscribe((pizza: Pizza) => {
flag = true;
expect(pizza.model.toppings).toBe('oli');
expect(pizza.model.crust).toBe('thin');
});
expect(flag).toBe(true);
component.pizzaForm.patchValue({ toppings: 'olives', crust: 'thick' });
tick(200);
flag = false;
component.pizza$.pipe(take(1)).subscribe((pizza: Pizza) => {
flag = true;
expect(pizza.model.toppings).toBe('olives');
expect(pizza.model.crust).toBe('thick');
});
expect(flag).toBe(true);
}));
it('should set toppings prefix', fakeAsync(() => {
component.pizzaForm.patchValue({ toppings: 'cheese' });
tick(200);
component.onPrefix();
let flag = false;
tick(200);
component.pizza$.pipe(take(1)).subscribe((pizza: Pizza) => {
flag = true;
expect(pizza.model).toBeDefined();
expect(pizza.model.toppings).toBe('Mr. cheese');
expect(pizza.model.crust).toBe('thin');
});
expect(flag).toBe(true);
discardPeriodicTasks();
}));
it('should load data in pizza form', () => {
component.onLoadData();
let flag = false;
component.pizza$.pipe(take(1)).subscribe((pizza: Pizza) => {
flag = true;
expect(pizza.model.toppings).toBe('pineapple');
expect(pizza.model.crust).toBe('medium');
expect(pizza.model.extras).toEqual([false, false, true]);
});
//.........这里部分代码省略.........
示例2: it
it('should add a todo', () => {
component.addTodo('Get Milk');
component.addTodo('Clean Bathroom');
component.todos$.subscribe((state: Todo[]) => {
expect(state.length).toBe(2);
});
});