diff --git a/modules/angular2/src/mock/template_resolver_mock.js b/modules/angular2/src/mock/template_resolver_mock.js new file mode 100644 index 0000000000..fff3e575fb --- /dev/null +++ b/modules/angular2/src/mock/template_resolver_mock.js @@ -0,0 +1,28 @@ +import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection'; +import {Type, isPresent} from 'angular2/src/facade/lang'; + +import {Template} from 'angular2/src/core/annotations/template'; +import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; + +export class MockTemplateResolver extends TemplateResolver { + _cmpTemplates: Map; + + constructor() { + super(); + this._cmpTemplates = MapWrapper.create(); + } + + setTemplate(component: Type, template: Template) { + MapWrapper.set(this._cmpTemplates, component, template); + } + + resolve(component: Type): Template { + var override = MapWrapper.get(this._cmpTemplates, component); + + if (isPresent(override)) { + return override; + } + + return super.resolve(component); + } +} diff --git a/modules/angular2/test/core/compiler/integration_spec.js b/modules/angular2/test/core/compiler/integration_spec.js index 03fb217b15..d9da188f17 100644 --- a/modules/angular2/test/core/compiler/integration_spec.js +++ b/modules/angular2/test/core/compiler/integration_spec.js @@ -1,8 +1,6 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib'; import {DOM} from 'angular2/src/facade/dom'; -import {Map, MapWrapper} from 'angular2/src/facade/collection'; -import {Type, isPresent} from 'angular2/src/facade/lang'; import {Injector} from 'angular2/di'; import {Lexer, Parser, ChangeDetector, dynamicChangeDetection, @@ -12,7 +10,7 @@ import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler'; import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader'; import {NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy'; import {TemplateLoader} from 'angular2/src/core/compiler/template_loader'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; import {BindingPropagationConfig} from 'angular2/src/core/compiler/binding_propagation_config'; import {Decorator, Component, Viewport} from 'angular2/src/core/annotations/annotations'; @@ -37,7 +35,7 @@ export function main() { } beforeEach( () => { - tplResolver = new FakeTemplateResolver(); + tplResolver = new MockTemplateResolver(); compiler = createCompiler(tplResolver, dynamicChangeDetection); }); @@ -492,30 +490,6 @@ class MyService { } } -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -} - - class DoublePipe extends Pipe { supports(obj) { return true; @@ -534,4 +508,4 @@ class DoublePipeFactory { create() { return new DoublePipe(); } -} \ No newline at end of file +} diff --git a/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js b/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js index f1d6a80f28..1b30c55f2f 100644 --- a/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js +++ b/modules/angular2/test/core/compiler/shadow_dom/shadow_dom_emulation_integration_spec.js @@ -1,7 +1,7 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib'; -import {StringMapWrapper, MapWrapper, List} from 'angular2/src/facade/collection'; -import {isPresent, Type} from 'angular2/src/facade/lang'; +import {StringMapWrapper, List} from 'angular2/src/facade/collection'; +import {Type} from 'angular2/src/facade/lang'; import {Injector} from 'angular2/di'; import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection'; @@ -14,7 +14,7 @@ import {ShadowDomStrategy, NativeShadowDomStrategy, EmulatedShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy'; import {TemplateLoader} from 'angular2/src/core/compiler/template_loader'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; import {Decorator, Component, Viewport} from 'angular2/src/core/annotations/annotations'; import {Template} from 'angular2/src/core/annotations/template'; @@ -34,7 +34,7 @@ export function main() { var compiler, tplResolver; beforeEach(() => { - tplResolver = new FakeTemplateResolver(); + tplResolver = new MockTemplateResolver(); compiler = new Compiler(dynamicChangeDetection, new TemplateLoader(null), new DirectiveMetadataReader(), @@ -337,26 +337,3 @@ function createView(pv) { view.hydrate(new Injector([]), null, {}); return view; } - -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -} diff --git a/modules/angular2/test/directives/foreach_spec.js b/modules/angular2/test/directives/foreach_spec.js index ff95dd888a..cb88a91dca 100644 --- a/modules/angular2/test/directives/foreach_spec.js +++ b/modules/angular2/test/directives/foreach_spec.js @@ -1,8 +1,7 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib'; import {DOM} from 'angular2/src/facade/dom'; -import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection'; -import {Type, isPresent} from 'angular2/src/facade/lang'; +import {ListWrapper} from 'angular2/src/facade/collection'; import {Injector} from 'angular2/di'; import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection'; @@ -11,10 +10,11 @@ import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler'; import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader'; import {NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy'; import {TemplateLoader} from 'angular2/src/core/compiler/template_loader'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; -import {Decorator, Component, Viewport} from 'angular2/src/core/annotations/annotations'; import {Template} from 'angular2/src/core/annotations/template'; +import {Decorator, Component, Viewport} from 'angular2/src/core/annotations/annotations'; + +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; import {Foreach} from 'angular2/src/directives/foreach'; @@ -22,7 +22,7 @@ export function main() { describe('foreach', () => { var view, cd, compiler, component, tplResolver; beforeEach(() => { - tplResolver = new FakeTemplateResolver(); + tplResolver = new MockTemplateResolver(); compiler = new Compiler(dynamicChangeDetection, new TemplateLoader(null), new DirectiveMetadataReader(), new Parser(new Lexer()), new CompilerCache(), new NativeShadowDomStrategy(), tplResolver); @@ -234,26 +234,3 @@ class TestComponent { this.items = [1, 2]; } } - -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -} diff --git a/modules/angular2/test/directives/if_spec.js b/modules/angular2/test/directives/if_spec.js index ead5adeddc..b7baead930 100644 --- a/modules/angular2/test/directives/if_spec.js +++ b/modules/angular2/test/directives/if_spec.js @@ -1,8 +1,6 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el, IS_DARTIUM} from 'angular2/test_lib'; import {DOM} from 'angular2/src/facade/dom'; -import {Map, MapWrapper} from 'angular2/src/facade/collection'; -import {Type, isPresent} from 'angular2/src/facade/lang'; import {Injector} from 'angular2/di'; import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection'; @@ -11,11 +9,12 @@ import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler'; import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader'; import {NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy'; import {TemplateLoader} from 'angular2/src/core/compiler/template_loader'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; import {Component} from 'angular2/src/core/annotations/annotations'; import {Template} from 'angular2/src/core/annotations/template'; +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; + import {If} from 'angular2/src/directives/if'; export function main() { @@ -23,7 +22,7 @@ export function main() { var view, cd, compiler, component, tplResolver; beforeEach(() => { - tplResolver = new FakeTemplateResolver(); + tplResolver = new MockTemplateResolver(); compiler = new Compiler(dynamicChangeDetection, new TemplateLoader(null), new DirectiveMetadataReader(), new Parser(new Lexer()), new CompilerCache(), new NativeShadowDomStrategy(), tplResolver); @@ -219,26 +218,3 @@ class TestComponent { this.nullCondition = null; } } - -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -} diff --git a/modules/angular2/test/directives/non_bindable_spec.js b/modules/angular2/test/directives/non_bindable_spec.js index 3699374b79..fc1c35db13 100644 --- a/modules/angular2/test/directives/non_bindable_spec.js +++ b/modules/angular2/test/directives/non_bindable_spec.js @@ -1,7 +1,5 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib'; import {DOM} from 'angular2/src/facade/dom'; -import {Map, MapWrapper} from 'angular2/src/facade/collection'; -import {Type, isPresent} from 'angular2/src/facade/lang'; import {Injector} from 'angular2/di'; import {Lexer, Parser, ChangeDetector, dynamicChangeDetection} from 'angular2/change_detection'; import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler'; @@ -10,15 +8,15 @@ import {NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_str import {Decorator, Component} from 'angular2/src/core/annotations/annotations'; import {Template} from 'angular2/src/core/annotations/template'; import {TemplateLoader} from 'angular2/src/core/compiler/template_loader'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; import {NgElement} from 'angular2/src/core/dom/element'; import {NonBindable} from 'angular2/src/directives/non_bindable'; +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; export function main() { describe('non-bindable', () => { var view, cd, compiler, component, tplResolver; beforeEach(() => { - tplResolver = new FakeTemplateResolver(); + tplResolver = new MockTemplateResolver(); compiler = new Compiler(dynamicChangeDetection, new TemplateLoader(null), new DirectiveMetadataReader(), new Parser(new Lexer()), new CompilerCache(), new NativeShadowDomStrategy(), tplResolver); @@ -90,26 +88,3 @@ class TestDecorator { DOM.addClass(el.domElement, 'compiled'); } } - -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -} diff --git a/modules/angular2/test/directives/switch_spec.js b/modules/angular2/test/directives/switch_spec.js index 509b904b4e..c8ab1c62ae 100644 --- a/modules/angular2/test/directives/switch_spec.js +++ b/modules/angular2/test/directives/switch_spec.js @@ -1,7 +1,5 @@ import {describe, xit, it, expect, beforeEach, ddescribe, iit, el} from 'angular2/test_lib'; import {DOM} from 'angular2/src/facade/dom'; -import {Map, MapWrapper} from 'angular2/src/facade/collection'; -import {Type, isPresent} from 'angular2/src/facade/lang'; import {Injector} from 'angular2/di'; import {Lexer, Parser, dynamicChangeDetection} from 'angular2/change_detection'; import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler'; @@ -10,14 +8,14 @@ import {NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_str import {Component} from 'angular2/src/core/annotations/annotations'; import {Template} from 'angular2/src/core/annotations/template'; import {TemplateLoader} from 'angular2/core'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; import {Switch, SwitchWhen, SwitchDefault} from 'angular2/src/directives/switch'; +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; export function main() { describe('switch', () => { var view, cd, compiler, component, tplResolver; beforeEach(() => { - tplResolver = new FakeTemplateResolver(); + tplResolver = new MockTemplateResolver(); compiler = new Compiler(dynamicChangeDetection, new TemplateLoader(null), new DirectiveMetadataReader(), new Parser(new Lexer()), new CompilerCache(), new NativeShadowDomStrategy(), tplResolver); @@ -166,26 +164,3 @@ class TestComponent { this.when2 = null; } } - -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -} diff --git a/modules/angular2/test/forms/integration_spec.js b/modules/angular2/test/forms/integration_spec.js index ad3f0f4e8e..0ed81dc28a 100644 --- a/modules/angular2/test/forms/integration_spec.js +++ b/modules/angular2/test/forms/integration_spec.js @@ -6,13 +6,10 @@ import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler'; import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader'; import {NativeShadowDomStrategy} from 'angular2/src/core/compiler/shadow_dom_strategy'; import {TemplateLoader} from 'angular2/src/core/compiler/template_loader'; -import {TemplateResolver} from 'angular2/src/core/compiler/template_resolver'; +import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; import {Injector} from 'angular2/di'; -import {Map, MapWrapper} from 'angular2/src/facade/collection'; -import {Type, isPresent} from 'angular2/src/facade/lang'; - import {Component, Decorator, Template} from 'angular2/core'; import {ControlGroupDirective, ControlNameDirective, ControlDirective, NewControlGroupDirective, @@ -24,7 +21,7 @@ export function main() { } function compile(componentType, template, context, callback) { - var tplResolver = new FakeTemplateResolver(); + var tplResolver = new MockTemplateResolver(); var compiler = new Compiler(dynamicChangeDetection, new TemplateLoader(null), @@ -239,26 +236,3 @@ class WrappedValue { cd.valueAccessor = new WrappedValueAccessor(); } } - -class FakeTemplateResolver extends TemplateResolver { - _cmpTemplates: Map; - - constructor() { - super(); - this._cmpTemplates = MapWrapper.create(); - } - - setTemplate(component: Type, template: Template) { - MapWrapper.set(this._cmpTemplates, component, template); - } - - resolve(component: Type): Template { - var override = MapWrapper.get(this._cmpTemplates, component); - - if (isPresent(override)) { - return override; - } - - return super.resolve(component); - } -}