本文整理汇总了TypeScript中@angular/core/testing.describe函数的典型用法代码示例。如果您正苦于以下问题:TypeScript describe函数的具体用法?TypeScript describe怎么用?TypeScript describe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了describe函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
/* tslint:disable:no-unused-variable */
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import {
beforeEach, beforeEachProviders,
describe, xdescribe,
expect, it, xit,
async, inject
} from '@angular/core/testing';
import { EventListComponent } from './event-list.component';
import { EventService } from './../event.service';
describe('Component: EventList', () => {
it('should create an instance', () => {
let component = new EventListComponent(new EventService());
expect(component).toBeTruthy();
});
});
开发者ID:tstapler,项目名称:DJ-Alfred,代码行数:21,代码来源:event-list.component.spec.ts
示例2: describe
describe('user service', () => {
beforeEachProviders(() => [LoginService, UserService]);
it('should validate pins', inject([UserService], (service) => {
service.pin = 12345;
expect(service.isValidPin()).toBe(false);
service.pin = 0;
expect(service.isValidPin()).toBe(true);
service.pin = 9999;
expect(service.isValidPin()).toBe(true);
service.pin = -50;
expect(service.isValidPin()).toBe(false);
}));
it('should greet when pin is wrong', async(inject([UserService], (service) => {
service.pin = 9999;
service.getGreeting().then((greeting) => {
expect(greeting).toEqual('Login failure!');
});
})), 3000);
it('should greet when pin is right', async(inject([UserService], (service) => {
service.pin = 2015;
service.getGreeting().then((greeting) => {
expect(greeting).toEqual('Welcome!');
});
})), 3000);
});
开发者ID:FernandoVezzali,项目名称:ng2-test-seed,代码行数:31,代码来源:user-service_test.ts
示例3: describe
/* tslint:disable:no-unused-variable */
import {
beforeEach, beforeEachProviders,
describe, xdescribe,
expect, it, xit,
async, inject
} from '@angular/core/testing';
import { WishlistService } from './wishlist.service';
describe('Wishlist Service', () => {
beforeEachProviders(() => [WishlistService]);
it('should ...',
inject([WishlistService], (service: WishlistService) => {
expect(service).toBeTruthy();
}));
});
开发者ID:heinschulie,项目名称:hca-shell,代码行数:18,代码来源:wishlist.service.spec.ts
示例4: describe
// #docregion
import { describe, beforeEachProviders, it, inject } from '@angular/core/testing';
import OrderByPipe from '../../app/js/phone_list/order_by.pipe';
describe('OrderByPipe', () => {
let input:any[] = [
{name: 'Nexus S', snippet: 'The Nexus S Phone', images: []},
{name: 'Motorola DROID', snippet: 'An Android-for-business smartphone', images: []}
];
beforeEachProviders(() => [OrderByPipe]);
it('should order by the given property', inject([OrderByPipe], (orderByPipe) => {
expect(orderByPipe.transform(input, 'name')).toEqual([input[1], input[0]]);
}));
});
开发者ID:2947721120,项目名称:angular-cn-1,代码行数:19,代码来源:order_by.pipe.spec.ts
示例5: describe
describe('UserService Service', () => {
beforeEachProviders(() => [API_PROVIDERS]);
it('should contain authentication methods',
inject([UserApi], (service: UserApi) => {
expect(service).toBeTruthy();
expect(service.login).toBeTruthy();
expect(service.logout).toBeTruthy();
expect(service.getAccessTokens).toBeTruthy();
expect(service.getCurrent).toBeTruthy();
expect(service.getCurrentId).toBeTruthy();
})
);
it('should create a new instance',
inject([UserApi], (userApi: UserApi) => {
let user: User = new User();
user.email = Date.now() + '@test.com';
user.password = 'test';
return userApi.create(user)
.subscribe((user: User) => expect(user.id).toBeTruthy());
})
);
it('should login the user',
inject([UserApi], (userApi: UserApi) => {
let user: User = new User();
user.email = Date.now() + '@test.com';
user.password = 'test';
return userApi.create(user)
.subscribe((instance: User) => userApi.login(user)
.subscribe((token: TokenInterface) => {
expect(token.id).toBeTruthy();
expect(token.userId).toBe(instance.id);
}));
})
);
it('should logout the user',
inject([UserApi], (userApi: UserApi) => {
let user: User = new User();
user.email = Date.now() + '@test.com';
user.password = 'test';
return userApi.create(user)
.subscribe((instance: User) => userApi.login(user)
.subscribe((token: TokenInterface) => {
expect(token.id).toBeTruthy();
expect(token.userId).toBe(instance.id);
userApi.logout().subscribe((res: boolean) => {
expect(res).toBe(true);
});
}));
})
);
it('should fail login the user',
inject([UserApi], (userApi: UserApi) => {
return userApi.login({ email: '[email protected]', password: 'duh' })
.subscribe((res) => { }, err => expect(err.status).toEqual(401));
})
);
it('should get current user',
inject([UserApi], (userApi: UserApi) => {
let user: User = new User();
user.email = Date.now() + '@test.com';
user.password = 'test';
return userApi.create(user)
.subscribe((instance: User) => userApi.login(user)
.subscribe((token: TokenInterface) => userApi.getCurrent()
.subscribe((user: User) => expect(user.id).toBe(instance.id)
)));
}));
});
开发者ID:otabekgb,项目名称:loopback-sdk-builder,代码行数:74,代码来源:user-service.service.spec.ts
示例6: describe
/* tslint:disable:no-unused-variable */
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import {
beforeEach, beforeEachProviders,
describe, xdescribe,
expect, it, xit,
async, inject
} from '@angular/core/testing';
import { ProcessComponent } from './process.component';
describe('Component: Process', () => {
it('should create an instance', () => {
let component = new ProcessComponent();
expect(component).toBeTruthy();
});
});
开发者ID:tech4good-lab,项目名称:the-refugee-project,代码行数:20,代码来源:process.component.spec.ts
示例7: describe
describe('`NglPopoverBehavior`', () => {
it('should change visibility based on mouse', testAsync((fixture: ComponentFixture<TestComponent>) => {
fixture.detectChanges();
const triggerEl = fixture.nativeElement.firstElementChild;
triggerEl.dispatchEvent(new Event('mouseenter'));
setTimeout(() => {
expect(getPopoverElement(fixture.nativeElement)).toBeTruthy();
triggerEl.dispatchEvent(new Event('mouseleave'));
expect(getPopoverElement(fixture.nativeElement)).toBeFalsy();
});
}));
it('should change visibility based on focus', testAsync((fixture: ComponentFixture<TestComponent>) => {
fixture.detectChanges();
const triggerEl = fixture.nativeElement.firstElementChild;
triggerEl.dispatchEvent(new Event('focus'));
setTimeout(() => {
expect(getPopoverElement(fixture.nativeElement)).toBeTruthy();
triggerEl.dispatchEvent(new Event('blur'));
expect(getPopoverElement(fixture.nativeElement)).toBeFalsy();
});
}));
it('should create more than one instances', testAsync((fixture: ComponentFixture<TestComponent>) => {
fixture.detectChanges();
const triggerEl = fixture.nativeElement.firstElementChild;
triggerEl.dispatchEvent(new Event('focus'));
setTimeout(() => {
triggerEl.dispatchEvent(new Event('mouseenter'));
expect(fixture.nativeElement.querySelectorAll('ngl-popover').length).toBe(1);
});
}));
});
开发者ID:Nangal,项目名称:ng-lightning,代码行数:42,代码来源:behavior.spec.ts
示例8: describe
import {
beforeEachProviders,
it,
describe,
expect,
inject
} from '@angular/core/testing';
import { PmProductSrv } from './pm-services.service';
describe('PmServices Service', () => {
beforeEachProviders(() => [PmProductSrv]);
it('should ...',
inject([PmProductSrv], (service: PmProductSrv) => {
expect(service).toBeTruthy();
}));
});
开发者ID:robsjrn,项目名称:hozi,代码行数:17,代码来源:pm-services.service.spec.ts
示例9: describe
/* tslint:disable:no-unused-variable */
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';
import {
beforeEach, beforeEachProviders,
describe, xdescribe,
expect, it, xit,
async, inject
} from '@angular/core/testing';
import { ImageCarouselComponent } from './image-carousel.component';
describe('Component: ImageCarousel', () => {
it('should create an instance', () => {
// let component = new ImageCarouselComponent();
// expect(component).toBeTruthy();
});
});
开发者ID:heinschulie,项目名称:hca-shell,代码行数:20,代码来源:image-carousel.component.spec.ts
示例10: describe
describe('LocalStorageTaskService', () => {
beforeEach(() => {
spyOn(localStorage, 'getItem').and.callFake(function (key) {
return localStore[key];
});
spyOn(localStorage, 'setItem').and.callFake(function (key, value) {
return localStore[key] = value + '';
});
spyOn(localStorage, 'clear').and.callFake(function () {
localStore = {};
});
});
beforeEachProviders(() => [LocalStorageTaskService]);
it('can list all tasks', inject([LocalStorageTaskService], (service) => {
let tasks = service.list();
expect(tasks.every(task => task instanceof Task)).toBe(true);
expect(tasks.length).toBe(2);
expect(tasks[0].title).toBe('Task 1');
expect(tasks[1].title).toBe('Task 2');
}));
it('can add a task to the repository', inject([LocalStorageTaskService], (service) => {
let len = service.add({ title: 'Task 3', notes: 'Task 3 notes' });
let tasks = service.list();
expect(len).toBe(3);
expect(tasks[2].title).toBe('Task 3');
expect(tasks[2].notes).toBe('Task 3 notes');
}));
it('can remove the specified task from the repository', inject([LocalStorageTaskService], (service) => {
let tasks = service.list();
let taskToBeRemoved = tasks[0];
let removedTasks = service.remove(taskToBeRemoved);
expect(removedTasks.length).toBe(1);
expect(removedTasks[0].title).toBe('Task 1');
}));
it('can update details of the specified task', inject([LocalStorageTaskService], (service) => {
const NEW_TITLE = 'Task 1 (edited)';
let tasks = service.list();
let taskToUpdate = tasks[0];
taskToUpdate.title = NEW_TITLE;
let updatedTask = service.update(taskToUpdate);
expect(tasks[0].title).toBe(NEW_TITLE);
expect(updatedTask.title).toBe(NEW_TITLE);
}));
});
开发者ID:nfang,项目名称:haru,代码行数:49,代码来源:local_storage_task_service.spec.ts
注:本文中的@angular/core/testing.describe函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论