@ -19,7 +19,7 @@ import {
|
||||
JSONPBackend,
|
||||
JSONPBackend_
|
||||
} from 'angular2/src/http/backends/jsonp_backend';
|
||||
import {bind, Injector} from 'angular2/core';
|
||||
import {provide, Injector} from 'angular2/core';
|
||||
import {isPresent, StringWrapper} from 'angular2/src/core/facade/lang';
|
||||
import {TimerWrapper} from 'angular2/src/core/facade/async';
|
||||
import {Request} from 'angular2/src/http/static_request';
|
||||
@ -72,10 +72,9 @@ export function main() {
|
||||
|
||||
beforeEach(() => {
|
||||
let injector = Injector.resolveAndCreate([
|
||||
bind(ResponseOptions)
|
||||
.toClass(BaseResponseOptions),
|
||||
bind(BrowserJsonp).toClass(MockBrowserJsonp),
|
||||
bind(JSONPBackend).toClass(JSONPBackend_)
|
||||
provide(ResponseOptions, {asClass: BaseResponseOptions}),
|
||||
provide(BrowserJsonp, {asClass: MockBrowserJsonp}),
|
||||
provide(JSONPBackend, {asClass: JSONPBackend_})
|
||||
]);
|
||||
backend = injector.get(JSONPBackend);
|
||||
let base = new BaseRequestOptions();
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
import {ObservableWrapper} from 'angular2/src/core/facade/async';
|
||||
import {BrowserXhr} from 'angular2/src/http/backends/browser_xhr';
|
||||
import {MockConnection, MockBackend} from 'angular2/src/http/backends/mock_backend';
|
||||
import {bind, Injector} from 'angular2/core';
|
||||
import {provide, Injector} from 'angular2/core';
|
||||
import {Request} from 'angular2/src/http/static_request';
|
||||
import {Response} from 'angular2/src/http/static_response';
|
||||
import {Headers} from 'angular2/src/http/headers';
|
||||
@ -35,7 +35,7 @@ export function main() {
|
||||
|
||||
beforeEach(() => {
|
||||
var injector = Injector.resolveAndCreate(
|
||||
[bind(ResponseOptions).toClass(BaseResponseOptions), MockBackend]);
|
||||
[provide(ResponseOptions, {asClass: BaseResponseOptions}), MockBackend]);
|
||||
backend = injector.get(MockBackend);
|
||||
var base = new BaseRequestOptions();
|
||||
sampleRequest1 = new Request(base.merge(new RequestOptions({url: 'https://google.com'})));
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
import {ObservableWrapper} from 'angular2/src/core/facade/async';
|
||||
import {BrowserXhr} from 'angular2/src/http/backends/browser_xhr';
|
||||
import {XHRConnection, XHRBackend} from 'angular2/src/http/backends/xhr_backend';
|
||||
import {bind, Injector} from 'angular2/core';
|
||||
import {provide, Injector} from 'angular2/core';
|
||||
import {Request} from 'angular2/src/http/static_request';
|
||||
import {Response} from 'angular2/src/http/static_response';
|
||||
import {Headers} from 'angular2/src/http/headers';
|
||||
@ -75,9 +75,8 @@ export function main() {
|
||||
|
||||
beforeEach(() => {
|
||||
var injector = Injector.resolveAndCreate([
|
||||
bind(ResponseOptions)
|
||||
.toClass(BaseResponseOptions),
|
||||
bind(BrowserXhr).toClass(MockBrowserXHR),
|
||||
provide(ResponseOptions, {asClass: BaseResponseOptions}),
|
||||
provide(BrowserXhr, {asClass: MockBrowserXHR}),
|
||||
XHRBackend
|
||||
]);
|
||||
backend = injector.get(XHRBackend);
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
xit,
|
||||
SpyObject
|
||||
} from 'angular2/test_lib';
|
||||
import {Injector, bind} from 'angular2/core';
|
||||
import {Injector, provide} from 'angular2/core';
|
||||
import {MockBackend, MockConnection} from 'angular2/src/http/backends/mock_backend';
|
||||
import {
|
||||
BaseRequestOptions,
|
||||
@ -22,8 +22,8 @@ import {
|
||||
Response,
|
||||
ResponseOptions,
|
||||
URLSearchParams,
|
||||
JSONP_BINDINGS,
|
||||
HTTP_BINDINGS,
|
||||
JSONP_PROVIDERS,
|
||||
HTTP_PROVIDERS,
|
||||
XHRBackend,
|
||||
JSONPBackend,
|
||||
Http,
|
||||
@ -58,14 +58,16 @@ export function main() {
|
||||
|
||||
it('should allow using jsonpInjectables and httpInjectables in same injector',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
parentInjector = Injector.resolveAndCreate(
|
||||
[bind(XHRBackend).toClass(MockBackend), bind(JSONPBackend).toClass(MockBackend)]);
|
||||
parentInjector = Injector.resolveAndCreate([
|
||||
provide(XHRBackend, {asClass: MockBackend}),
|
||||
provide(JSONPBackend, {asClass: MockBackend})
|
||||
]);
|
||||
|
||||
childInjector = parentInjector.resolveAndCreateChild([
|
||||
HTTP_BINDINGS,
|
||||
JSONP_BINDINGS,
|
||||
bind(XHRBackend).toClass(MockBackend),
|
||||
bind(JSONPBackend).toClass(MockBackend)
|
||||
HTTP_PROVIDERS,
|
||||
JSONP_PROVIDERS,
|
||||
provide(XHRBackend, {asClass: MockBackend}),
|
||||
provide(JSONPBackend, {asClass: MockBackend})
|
||||
]);
|
||||
|
||||
http = childInjector.get(Http);
|
||||
@ -110,16 +112,22 @@ export function main() {
|
||||
injector = Injector.resolveAndCreate([
|
||||
BaseRequestOptions,
|
||||
MockBackend,
|
||||
bind(Http).toFactory(
|
||||
function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
|
||||
return new Http(backend, defaultOptions);
|
||||
},
|
||||
[MockBackend, BaseRequestOptions]),
|
||||
bind(Jsonp).toFactory(
|
||||
function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
|
||||
return new Jsonp(backend, defaultOptions);
|
||||
},
|
||||
[MockBackend, BaseRequestOptions])
|
||||
provide(
|
||||
Http,
|
||||
{
|
||||
asFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
|
||||
return new Http(backend, defaultOptions);
|
||||
},
|
||||
deps: [MockBackend, BaseRequestOptions]
|
||||
}),
|
||||
provide(
|
||||
Jsonp,
|
||||
{
|
||||
asFactory: function(backend: ConnectionBackend, defaultOptions: BaseRequestOptions) {
|
||||
return new Jsonp(backend, defaultOptions);
|
||||
},
|
||||
deps: [MockBackend, BaseRequestOptions]
|
||||
})
|
||||
]);
|
||||
http = injector.get(Http);
|
||||
jsonp = injector.get(Jsonp);
|
||||
|
Reference in New Issue
Block a user