@@ -1,17 +1,4 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xdescribe,
|
||||
Log,
|
||||
xit
|
||||
} from 'angular2/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, afterEach, ddescribe, describe, expect, iit, inject, it, xdescribe, Log, xit} from 'angular2/testing_internal';
|
||||
import {IS_DART, isPresent, stringify} from 'angular2/src/facade/lang';
|
||||
import {bootstrap} from 'angular2/platform/browser';
|
||||
import {ApplicationRef} from 'angular2/src/core/application_ref';
|
||||
@@ -25,7 +12,7 @@ import {provide, Inject, Injector, PLATFORM_INITIALIZER, APP_INITIALIZER} from '
|
||||
import {disposePlatform} from 'angular2/src/core/application_ref';
|
||||
import {ExceptionHandler, BaseException} from 'angular2/src/facade/exceptions';
|
||||
import {Testability, TestabilityRegistry} from 'angular2/src/core/testability/testability';
|
||||
import {ComponentRef_, ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
|
||||
import {ComponentRef_, ComponentRef} from 'angular2/src/core/linker/dynamic_component_loader';
|
||||
|
||||
@Component({selector: 'hello-app', template: '{{greeting}} world!'})
|
||||
class HelloRootCmp {
|
||||
@@ -48,7 +35,7 @@ class HelloRootCmp2 {
|
||||
class HelloRootCmp3 {
|
||||
appBinding;
|
||||
|
||||
constructor(@Inject("appBinding") appBinding) { this.appBinding = appBinding; }
|
||||
constructor(@Inject('appBinding') appBinding) { this.appBinding = appBinding; }
|
||||
}
|
||||
|
||||
@Component({selector: 'hello-app', template: ''})
|
||||
@@ -110,14 +97,14 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var logger = new _ArrayLogger();
|
||||
var exceptionHandler = new ExceptionHandler(logger, false);
|
||||
var refPromise =
|
||||
bootstrap(HelloRootDirectiveIsNotCmp,
|
||||
[testProviders, provide(ExceptionHandler, {useValue: exceptionHandler})]);
|
||||
var refPromise = bootstrap(
|
||||
HelloRootDirectiveIsNotCmp,
|
||||
[testProviders, provide(ExceptionHandler, {useValue: exceptionHandler})]);
|
||||
|
||||
PromiseWrapper.then(refPromise, null, (exception) => {
|
||||
expect(exception).toContainError(
|
||||
`Could not compile '${stringify(HelloRootDirectiveIsNotCmp)}' because it is not a component.`);
|
||||
expect(logger.res.join("")).toContain("Could not compile");
|
||||
expect(logger.res.join('')).toContain('Could not compile');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
@@ -159,7 +146,7 @@ export function main() {
|
||||
var refPromise =
|
||||
bootstrap(HelloRootCmp, [provide(ExceptionHandler, {useValue: exceptionHandler})]);
|
||||
PromiseWrapper.then(refPromise, null, (reason) => {
|
||||
expect(logger.res.join(""))
|
||||
expect(logger.res.join(''))
|
||||
.toContain('The selector "hello-app" did not match any elements');
|
||||
async.done();
|
||||
return null;
|
||||
@@ -183,46 +170,43 @@ export function main() {
|
||||
it('should support multiple calls to bootstrap', inject([AsyncTestCompleter], (async) => {
|
||||
var refPromise1 = bootstrap(HelloRootCmp, testProviders);
|
||||
var refPromise2 = bootstrap(HelloRootCmp2, testProviders);
|
||||
PromiseWrapper.all([refPromise1, refPromise2])
|
||||
.then((refs) => {
|
||||
expect(el).toHaveText('hello world!');
|
||||
expect(el2).toHaveText('hello world, again!');
|
||||
async.done();
|
||||
});
|
||||
PromiseWrapper.all([refPromise1, refPromise2]).then((refs) => {
|
||||
expect(el).toHaveText('hello world!');
|
||||
expect(el2).toHaveText('hello world, again!');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not crash if change detection is invoked when the root component is disposed',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
bootstrap(HelloOnDestroyTickCmp, testProviders)
|
||||
.then((ref) => {
|
||||
expect(() => ref.dispose()).not.toThrow();
|
||||
async.done();
|
||||
});
|
||||
bootstrap(HelloOnDestroyTickCmp, testProviders).then((ref) => {
|
||||
expect(() => ref.dispose()).not.toThrow();
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should unregister change detectors when components are disposed',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var app = platform(BROWSER_PROVIDERS).application([BROWSER_APP_PROVIDERS, testProviders]);
|
||||
app.bootstrap(HelloRootCmp)
|
||||
.then((ref) => {
|
||||
ref.dispose();
|
||||
expect(() => app.tick()).not.toThrow();
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it("should make the provided bindings available to the application component",
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var refPromise = bootstrap(
|
||||
HelloRootCmp3, [testProviders, provide("appBinding", {useValue: "BoundValue"})]);
|
||||
|
||||
refPromise.then((ref) => {
|
||||
expect(ref.hostComponent.appBinding).toEqual("BoundValue");
|
||||
app.bootstrap(HelloRootCmp).then((ref) => {
|
||||
ref.dispose();
|
||||
expect(() => app.tick()).not.toThrow();
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it("should avoid cyclic dependencies when root component requires Lifecycle through DI",
|
||||
it('should make the provided bindings available to the application component',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var refPromise = bootstrap(
|
||||
HelloRootCmp3, [testProviders, provide('appBinding', {useValue: 'BoundValue'})]);
|
||||
|
||||
refPromise.then((ref) => {
|
||||
expect(ref.hostComponent.appBinding).toEqual('BoundValue');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should avoid cyclic dependencies when root component requires Lifecycle through DI',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var refPromise = bootstrap(HelloRootCmp4, testProviders);
|
||||
|
||||
@@ -232,21 +216,21 @@ export function main() {
|
||||
});
|
||||
}));
|
||||
|
||||
it("should run platform initializers", inject([Log], (log: Log) => {
|
||||
it('should run platform initializers', inject([Log], (log: Log) => {
|
||||
let p = platform([
|
||||
BROWSER_PROVIDERS,
|
||||
provide(PLATFORM_INITIALIZER, {useValue: log.fn("platform_init1"), multi: true}),
|
||||
provide(PLATFORM_INITIALIZER, {useValue: log.fn("platform_init2"), multi: true})
|
||||
provide(PLATFORM_INITIALIZER, {useValue: log.fn('platform_init1'), multi: true}),
|
||||
provide(PLATFORM_INITIALIZER, {useValue: log.fn('platform_init2'), multi: true})
|
||||
]);
|
||||
expect(log.result()).toEqual("platform_init1; platform_init2");
|
||||
expect(log.result()).toEqual('platform_init1; platform_init2');
|
||||
log.clear();
|
||||
p.application([
|
||||
BROWSER_APP_PROVIDERS,
|
||||
provide(APP_INITIALIZER, {useValue: log.fn("app_init1"), multi: true}),
|
||||
provide(APP_INITIALIZER, {useValue: log.fn("app_init2"), multi: true})
|
||||
provide(APP_INITIALIZER, {useValue: log.fn('app_init1'), multi: true}),
|
||||
provide(APP_INITIALIZER, {useValue: log.fn('app_init2'), multi: true})
|
||||
]);
|
||||
|
||||
expect(log.result()).toEqual("app_init1; app_init2");
|
||||
expect(log.result()).toEqual('app_init1; app_init2');
|
||||
}));
|
||||
|
||||
it('should register each application with the testability registry',
|
||||
@@ -254,18 +238,16 @@ export function main() {
|
||||
var refPromise1: Promise<ComponentRef> = bootstrap(HelloRootCmp, testProviders);
|
||||
var refPromise2: Promise<ComponentRef> = bootstrap(HelloRootCmp2, testProviders);
|
||||
|
||||
PromiseWrapper.all([refPromise1, refPromise2])
|
||||
.then((refs: ComponentRef[]) => {
|
||||
var registry = refs[0].injector.get(TestabilityRegistry);
|
||||
var testabilities =
|
||||
[refs[0].injector.get(Testability), refs[1].injector.get(Testability)];
|
||||
PromiseWrapper.all(testabilities)
|
||||
.then((testabilities: Testability[]) => {
|
||||
expect(registry.findTestabilityInTree(el)).toEqual(testabilities[0]);
|
||||
expect(registry.findTestabilityInTree(el2)).toEqual(testabilities[1]);
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
PromiseWrapper.all([refPromise1, refPromise2]).then((refs: ComponentRef[]) => {
|
||||
var registry = refs[0].injector.get(TestabilityRegistry);
|
||||
var testabilities =
|
||||
[refs[0].injector.get(Testability), refs[1].injector.get(Testability)];
|
||||
PromiseWrapper.all(testabilities).then((testabilities: Testability[]) => {
|
||||
expect(registry.findTestabilityInTree(el)).toEqual(testabilities[0]);
|
||||
expect(registry.findTestabilityInTree(el2)).toEqual(testabilities[1]);
|
||||
async.done();
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
inject,
|
||||
ddescribe,
|
||||
describe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
SpyObject
|
||||
} from 'angular2/testing_internal';
|
||||
import {AsyncTestCompleter, inject, ddescribe, describe, it, iit, xit, expect, SpyObject} from 'angular2/testing_internal';
|
||||
import {SpyElementRef, SpyDomAdapter} from '../../core/spies';
|
||||
|
||||
import {DOM, DomAdapter} from 'angular2/src/platform/dom/dom_adapter';
|
||||
@@ -43,7 +33,7 @@ export function main() {
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
var ruler = new Ruler(DOM);
|
||||
var elRef = <any>new SpyElementRef();
|
||||
elRef.prop("nativeElement", DOM.createElement('div'));
|
||||
elRef.prop('nativeElement', DOM.createElement('div'));
|
||||
ruler.measure(elRef).then((rect) => {
|
||||
// here we are using an element created in a doc fragment so all the measures will come
|
||||
// back as 0
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
afterEach,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit
|
||||
} from 'angular2/testing_internal';
|
||||
import {afterEach, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from 'angular2/testing_internal';
|
||||
|
||||
import {enableDebugTools, disableDebugTools} from 'angular2/platform/browser';
|
||||
import {SpyComponentRef, callNgProfilerTimeChangeDetection} from './spies';
|
||||
|
||||
@@ -1,21 +1,6 @@
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {UrlResolver, XHR} from 'angular2/compiler';
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
beforeEachProviders,
|
||||
ComponentFixture,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
fakeAsync,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
TestComponentBuilder,
|
||||
tick,
|
||||
xit
|
||||
} from 'angular2/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, beforeEachProviders, ComponentFixture, ddescribe, describe, expect, fakeAsync, iit, inject, it, TestComponentBuilder, tick, xit} from 'angular2/testing_internal';
|
||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
import {CachedXHR} from 'angular2/src/platform/browser/xhr_cache';
|
||||
import {setTemplateCache} from './xhr_cache_setter';
|
||||
@@ -28,26 +13,25 @@ export function main() {
|
||||
setTemplateCache({'test.html': '<div>Hello</div>'});
|
||||
return new CachedXHR();
|
||||
}
|
||||
beforeEachProviders(() => [
|
||||
provide(UrlResolver, {useClass: TestUrlResolver}),
|
||||
provide(XHR, {useFactory: createCachedXHR})
|
||||
]);
|
||||
beforeEachProviders(() => [provide(UrlResolver, {useClass: TestUrlResolver}), provide(XHR, {
|
||||
useFactory: createCachedXHR
|
||||
})]);
|
||||
|
||||
it('should throw exception if $templateCache is not found', () => {
|
||||
setTemplateCache(null);
|
||||
expect(() => { xhr = new CachedXHR(); })
|
||||
.toThrowErrorWith('CachedXHR: Template cache was not found in $templateCache.');
|
||||
expect(() => {
|
||||
xhr = new CachedXHR();
|
||||
}).toThrowErrorWith('CachedXHR: Template cache was not found in $templateCache.');
|
||||
});
|
||||
|
||||
it('should resolve the Promise with the cached file content on success',
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
setTemplateCache({'test.html': '<div>Hello</div>'});
|
||||
xhr = new CachedXHR();
|
||||
xhr.get('test.html')
|
||||
.then((text) => {
|
||||
expect(text).toEqual('<div>Hello</div>');
|
||||
async.done();
|
||||
});
|
||||
xhr.get('test.html').then((text) => {
|
||||
expect(text).toEqual('<div>Hello</div>');
|
||||
async.done();
|
||||
});
|
||||
}));
|
||||
|
||||
it('should reject the Promise on failure', inject([AsyncTestCompleter], (async) => {
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit
|
||||
} from 'angular2/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xit} from 'angular2/testing_internal';
|
||||
|
||||
import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
el,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
beforeEachProviders,
|
||||
SpyObject,
|
||||
} from 'angular2/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, el, expect, iit, inject, it, xit, beforeEachProviders, SpyObject,} from 'angular2/testing_internal';
|
||||
|
||||
// import {MapWrapper} from 'angular2/src/facade/collection';
|
||||
// import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
describe,
|
||||
ddescribe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
xdescribe,
|
||||
expect,
|
||||
beforeEach,
|
||||
el
|
||||
} from 'angular2/testing_internal';
|
||||
import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach, el} from 'angular2/testing_internal';
|
||||
import {EventManager, EventManagerPlugin} from 'angular2/platform/common_dom';
|
||||
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
|
||||
import {NgZone} from 'angular2/src/core/zone/ng_zone';
|
||||
@@ -79,7 +69,7 @@ export function main() {
|
||||
var handler = (e) => { receivedEvent = e; };
|
||||
var manager = new EventManager([domEventPlugin], new FakeNgZone());
|
||||
|
||||
var remover = manager.addGlobalEventListener("document", 'click', handler);
|
||||
var remover = manager.addGlobalEventListener('document', 'click', handler);
|
||||
DOM.dispatchEvent(element, dispatchedEvent);
|
||||
expect(receivedEvent).toBe(dispatchedEvent);
|
||||
|
||||
|
||||
@@ -1,14 +1,4 @@
|
||||
import {
|
||||
describe,
|
||||
ddescribe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
xdescribe,
|
||||
expect,
|
||||
beforeEach,
|
||||
el
|
||||
} from 'angular2/testing_internal';
|
||||
import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach, el} from 'angular2/testing_internal';
|
||||
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';
|
||||
|
||||
export function main() {
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
xdescribe,
|
||||
describe,
|
||||
el,
|
||||
dispatchEvent,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
beforeEachProviders,
|
||||
it,
|
||||
xit,
|
||||
SpyObject,
|
||||
proxy
|
||||
} from 'angular2/testing_internal';
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, xdescribe, describe, el, dispatchEvent, expect, iit, inject, beforeEachProviders, it, xit, SpyObject, proxy} from 'angular2/testing_internal';
|
||||
|
||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
import {DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
|
||||
|
||||
Reference in New Issue
Block a user