当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript MockConnection.mockRespond方法代码示例

本文整理汇总了TypeScript中@angular/http/testing.MockConnection.mockRespond方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MockConnection.mockRespond方法的具体用法?TypeScript MockConnection.mockRespond怎么用?TypeScript MockConnection.mockRespond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/http/testing.MockConnection的用法示例。


在下文中一共展示了MockConnection.mockRespond方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ResponseOptions

 backend.connections.subscribe((connection: MockConnection) => {
     let options = new ResponseOptions({
         body: JSON.stringify(result)
     });
     connection.mockRespond(new Response(options));
 });
开发者ID:sandormiko,项目名称:gb-calculator,代码行数:6,代码来源:calculation.service.spec.ts

示例2: ResponseOptions

 mockBackend.connections.subscribe((c: MockConnection) => {
     calledRequestMethod = c.request.method;
     let options = new ResponseOptions({ status: 200, body: hero });
     var response = new Response(options);
     c.mockRespond(response);
 });
开发者ID:mmanela,项目名称:NetCoreHeroes,代码行数:6,代码来源:hero.service.spec.ts

示例3:

 .subscribe((response: Response) => {
     connection.mockRespond(response);
 },
开发者ID:ant38,项目名称:MyHotel,代码行数:3,代码来源:fake-backend.ts

示例4: ResponseOptions

 mock_backend.connections.subscribe((connection: MockConnection) => {
   let options = new ResponseOptions({
     body: json
   });
   connection.mockRespond(new Response(options));
 });
开发者ID:MarcosPrieto,项目名称:Angular-AlbumStoreProductPage,代码行数:6,代码来源:product-service-getproducts-method-maps-response-to-json.projects.spec.ts

示例5: expect

 mockBackend.connections.subscribe((mockConnection:MockConnection)=>{
     expect(mockConnection.request.headers.get('userKey')).toBeDefined();
     expect(mockConnection.request.headers.get('userKey')).toEqual(userKey);
     expect(mockConnection.request.method).toBe(RequestMethod.Post);
     mockConnection.mockRespond( new Response(new ResponseOptions({body: login_response})));
 });
开发者ID:shafihuzaib,项目名称:cdp-ng-boilerplate,代码行数:6,代码来源:auth-api-service.spec.ts

示例6:

 backend.connections.subscribe((c: MockConnection) => {
     c.mockRespond(baseResponse);
 });
开发者ID:kmark1625,项目名称:free-code-camp,代码行数:3,代码来源:local-weather.service.spec.ts

示例7: Response

 (connection: MockConnection) => {
     connection.mockRespond(new Response(
         new ResponseOptions({ body: shopItemData })
     ));
 }
开发者ID:faxad,项目名称:cartify,代码行数:5,代码来源:shop-item-list.component.spec.ts

示例8: expect

 mockBackend.connections.subscribe((mockConnection:MockConnection)=>{
     expect(mockConnection.request.method).toBe(RequestMethod.Get);
     expect(mockConnection.request.url).toEqual(prepareUrl(baseUrl,url));
     mockConnection.mockRespond( new Response(new ResponseOptions({body: mockResponse})));
 });
开发者ID:shafihuzaib,项目名称:cdp-ng-boilerplate,代码行数:5,代码来源:api-service.spec.ts

示例9: Response

	mockBackend.connections.subscribe((connection: MockConnection) => {
		// POST create item request
		if (connection.request.method === 1 && connection.request.url.search(/tenants/i) > -1) {
			connection.mockRespond(new Response(new ResponseOptions({
				body: JSON.stringify({ data: JSON.parse(connection.request.getBody()) }),
				status: 200,
				statusText: "OK",
			})));
			return;
		}

		// POST update 'a1' (TenantOne) item request
		if (connection.request.method === 1 && connection.request.url.search(/tenants\/a1/i) > -1) {
			connection.mockRespond(new Response(new ResponseOptions({
				body: JSON.stringify({ data: TenantOne }),
				status: 200,
				statusText: "OK",
			})));
			return;
		}

		// GET form model request
		if (connection.request.url.search(/tenants\/form-model/i) > -1) {
			connection.mockRespond(new Response(new ResponseOptions({
				body: JSON.stringify(FORM_MODEL),
				status: 200,
				statusText: "OK",
			})));
			return;
		}

		// GET form data request
		if (connection.request.url.search(/tenants\/form-data/i) > -1) {
			connection.mockRespond(new Response(new ResponseOptions({
				body: JSON.stringify(FORM_DATA),
				status: 200,
				statusText: "OK",
			})));
			return;
		}

		// GET 'a1' (TenantOne) item data request
		if (connection.request.url.search(/tenants\/a1/i) > -1) {
			connection.mockRespond(new Response(new ResponseOptions({
				body: JSON.stringify({ data: TenantOne }),
				status: 200,
				statusText: "OK",
			})));
			return;
		}

		// GET 'b2' (TenantTwo) item data request
		if (connection.request.url.search(/tenants\/b2/i) > -1) {
			connection.mockRespond(new Response(new ResponseOptions({
				body: JSON.stringify({ data: TenantTwo }),
				status: 200,
				statusText: "OK",
			})));
			return;
		}
	});
开发者ID:llstarscreamll,项目名称:multi-tenant-app,代码行数:61,代码来源:tenant-testing.util.ts

示例10: expect

 backend.connections.subscribe((connection: MockConnection) => {
   expect(connection.request.method).toBe(RequestMethod.Get);
   expect(connection.request.url).toBe('http://localhost:8080/application');
   connection.mockRespond(new Response(new ResponseOptions({body: '{"expects": "JSON"}', status: 200})));
   count++;
 });
开发者ID:Vector-USS,项目名称:SECCION_4,代码行数:6,代码来源:nav.service.spec.ts


注:本文中的@angular/http/testing.MockConnection.mockRespond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。