本文整理匯總了TypeScript中app/services.UserMicropostService類的典型用法代碼示例。如果您正苦於以下問題:TypeScript UserMicropostService類的具體用法?TypeScript UserMicropostService怎麽用?TypeScript UserMicropostService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了UserMicropostService類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('UserMicropostService', () => {
var userMicropostService:UserMicropostService;
var backend:MockBackend;
beforeEachProviders(() => [APP_TEST_PROVIDERS]);
beforeEach(inject([UserMicropostService, MockBackend], (..._) => {
[userMicropostService, backend] = _;
}));
describe('.list', () => {
it("can list user's posts", (done) => {
backend.connections.subscribe(conn => {
conn.mockRespond(new Response(new ResponseOptions({
body: JSON.stringify(dummyJson),
})));
expect(conn.request.method).toEqual(RequestMethod.Get);
expect(conn.request.url).toEqual('/api/users/1/microposts?maxId=2&count=3');
});
userMicropostService.list('1', {maxId: 2, count: 3}).subscribe(res => {
expect(res).toEqual(dummyJson);
done();
});
});
}); // .list
});
示例2: it
it("can list user's posts", (done) => {
backend.connections.subscribe(conn => {
conn.mockRespond(new Response(new ResponseOptions({
body: JSON.stringify(dummyJson),
})));
expect(conn.request.method).toEqual(RequestMethod.Get);
expect(conn.request.url).toEqual('/api/users/1/microposts?maxId=2&count=3');
});
userMicropostService.list('1', {maxId: 2, count: 3}).subscribe(res => {
expect(res).toEqual(dummyJson);
done();
});
});