本文整理匯總了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);
});
});