本文整理汇总了TypeScript中app/services/store.TodoService类的典型用法代码示例。如果您正苦于以下问题:TypeScript TodoService类的具体用法?TypeScript TodoService怎么用?TypeScript TodoService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TodoService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('TodoStore', () => {
let service: TodoService;
let localStorage: MockLocalStorageService;
beforeEach(() => {
objects = [
new Todo({ id: 1, title: 'one' }),
new Todo({ id: 2, title: 'two' }),
new Todo({ id: 3, title: 'three' })
];
localStorage = new MockLocalStorageService();
service = new TodoService(localStorage as any);
});
it('should create a service', () => {
expect(service).not.to.be.null;
});
it('should return an Observable of Todos', async () => {
const result = await service.get().toPromise();
expect(result).to.deep.equal(objects);
expect(result).not.to.equal(objects);
});
it('should add a new Todo', async () => {
const result = await service.add('four').toPromise();
expect(result).to.have.lengthOf(4);
expect(result[3].title).to.equal('four');
});
it('should update a Todo', async () => {
const todo = objects[1];
todo.title = 'two edited';
const result = await service.update(todo).toPromise();
expect(result).to.have.lengthOf(3);
expect(result[1]).to.deep.equal(todo);
expect(result[1]).not.to.equal(todo);
});
it('should set new Todos', async () => {
const todos = [
new Todo({ title: 'foo' }),
new Todo({ title: 'bar' })
];
const result = await service.set(todos).toPromise();
expect(result).to.have.lengthOf(2);
expect(result).to.be.deep.equal(todos);
expect(result).not.to.equal(todos);
});
it('should delete a Todo', async () => {
const original = [...objects];
const result = await service.delete(objects[1]).toPromise();
expect(result).to.have.lengthOf(2);
expect(result[0]).to.deep.equal(original[0]);
expect(result[1]).to.deep.equal(original[2]);
});
});
开发者ID:jason0x43,项目名称:intern-examples,代码行数:58,代码来源:store.ts
示例2: async
it('should delete a Todo', async () => {
const original = [...objects];
const result = await service.delete(objects[1]).toPromise();
expect(result).to.have.lengthOf(2);
expect(result[0]).to.deep.equal(original[0]);
expect(result[1]).to.deep.equal(original[2]);
});
开发者ID:jason0x43,项目名称:intern-examples,代码行数:7,代码来源:store.ts
示例3: Todo
it('should set new Todos', async () => {
const todos = [
new Todo({ title: 'foo' }),
new Todo({ title: 'bar' })
];
const result = await service.set(todos).toPromise();
expect(result).to.have.lengthOf(2);
expect(result).to.be.deep.equal(todos);
expect(result).not.to.equal(todos);
});
开发者ID:jason0x43,项目名称:intern-examples,代码行数:10,代码来源:store.ts
注:本文中的app/services/store.TodoService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论