chore(test): migrate Dart tests to package:test
Instead of running with karma and the karma-dart shim, run dart tests directly using the new package:test runner. This migrates away from package:unittest. Fixes a couple tests, mostly associated with depending on absolute URLs or editing the test providers after an injector had already been created. Remove karma-dart and associated files. Change gupfiles to run tests via `pub run test` instead.
This commit is contained in:
@ -23,6 +23,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
transformer_test: '^0.2.0'
|
||||
guinness: '^0.1.18'
|
||||
guinness2: '0.0.5'
|
||||
quiver: '^0.21.4'
|
||||
test: '^0.12.6'
|
||||
transformers:
|
||||
|
@ -2,7 +2,7 @@ library testing.matchers;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:guinness/guinness.dart' as gns;
|
||||
import 'package:guinness2/guinness2.dart' as gns;
|
||||
|
||||
import 'package:angular2/src/platform/dom/dom_adapter.dart' show DOM;
|
||||
|
||||
|
@ -1,92 +1,30 @@
|
||||
library angular2.src.testing.testing_internal;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:guinness/guinness.dart' as gns;
|
||||
export 'package:guinness/guinness.dart'
|
||||
import 'testing_internal_core.dart' as core;
|
||||
export 'testing_internal_core.dart'
|
||||
hide
|
||||
Expect,
|
||||
expect,
|
||||
NotExpect,
|
||||
beforeEachProviders,
|
||||
beforeEachBindings,
|
||||
beforeEach,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
SpyObject,
|
||||
SpyFunction;
|
||||
testSetup,
|
||||
describe,
|
||||
ddescribe,
|
||||
xdescribe;
|
||||
|
||||
export 'matchers.dart' show expect, Expect, NotExpect;
|
||||
import 'package:angular2/platform/testing/browser.dart';
|
||||
|
||||
import 'package:angular2/src/core/reflection/reflection.dart';
|
||||
import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
|
||||
|
||||
import 'package:angular2/src/core/di/provider.dart' show bind;
|
||||
import 'package:angular2/src/facade/collection.dart' show StringMapWrapper;
|
||||
|
||||
import 'test_injector.dart';
|
||||
export 'test_injector.dart' show inject;
|
||||
|
||||
TestInjector _testInjector = getTestInjector();
|
||||
bool _isCurrentTestAsync;
|
||||
Future _currentTestFuture;
|
||||
bool _inIt = false;
|
||||
|
||||
class AsyncTestCompleter {
|
||||
final _completer = new Completer();
|
||||
|
||||
AsyncTestCompleter() {
|
||||
_currentTestFuture = this.future;
|
||||
}
|
||||
|
||||
void done() {
|
||||
_completer.complete();
|
||||
}
|
||||
|
||||
Future get future => _completer.future;
|
||||
}
|
||||
|
||||
void testSetup() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
// beforeEach configuration:
|
||||
// - Priority 3: clear the bindings before each test,
|
||||
// - Priority 2: collect the bindings before each test, see beforeEachProviders(),
|
||||
// - Priority 1: create the test injector to be used in beforeEach() and it()
|
||||
|
||||
gns.beforeEach(() {
|
||||
_testInjector.reset();
|
||||
_currentTestFuture = null;
|
||||
}, priority: 3);
|
||||
|
||||
var completerProvider = bind(AsyncTestCompleter).toFactory(() {
|
||||
// Mark the test as async when an AsyncTestCompleter is injected in an it(),
|
||||
if (!_inIt) throw 'AsyncTestCompleter can only be injected in an "it()"';
|
||||
_isCurrentTestAsync = true;
|
||||
return new AsyncTestCompleter();
|
||||
});
|
||||
|
||||
gns.beforeEach(() {
|
||||
_isCurrentTestAsync = false;
|
||||
_testInjector.addProviders([completerProvider]);
|
||||
}, priority: 1);
|
||||
core.setDartBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows overriding default providers defined in test_injector.js.
|
||||
*
|
||||
* The given function must return a list of DI providers.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* beforeEachProviders(() => [
|
||||
* bind(Compiler).toClass(MockCompiler),
|
||||
* bind(SomeToken).toValue(myValue),
|
||||
* ]);
|
||||
*/
|
||||
void beforeEachProviders(Function fn) {
|
||||
gns.beforeEach(() {
|
||||
var providers = fn();
|
||||
if (providers != null) _testInjector.addProviders(providers);
|
||||
}, priority: 2);
|
||||
testSetup();
|
||||
core.beforeEachProviders(fn);
|
||||
}
|
||||
|
||||
@Deprecated('using beforeEachProviders instead')
|
||||
@ -95,72 +33,33 @@ void beforeEachBindings(Function fn) {
|
||||
}
|
||||
|
||||
void beforeEach(fn) {
|
||||
if (fn is! FunctionWithParamTokens) fn =
|
||||
new FunctionWithParamTokens([], fn, false);
|
||||
gns.beforeEach(() {
|
||||
_testInjector.execute(fn);
|
||||
});
|
||||
}
|
||||
|
||||
void _it(gnsFn, name, fn) {
|
||||
if (fn is! FunctionWithParamTokens) fn =
|
||||
new FunctionWithParamTokens([], fn, false);
|
||||
gnsFn(name, () {
|
||||
_inIt = true;
|
||||
_testInjector.execute(fn);
|
||||
_inIt = false;
|
||||
if (_isCurrentTestAsync) return _currentTestFuture;
|
||||
});
|
||||
testSetup();
|
||||
core.beforeEach(fn);
|
||||
}
|
||||
|
||||
void it(name, fn, [timeOut = null]) {
|
||||
_it(gns.it, name, fn);
|
||||
core.it(name, fn, timeOut);
|
||||
}
|
||||
|
||||
void iit(name, fn, [timeOut = null]) {
|
||||
_it(gns.iit, name, fn);
|
||||
core.iit(name, fn, timeOut);
|
||||
}
|
||||
|
||||
void xit(name, fn, [timeOut = null]) {
|
||||
_it(gns.xit, name, fn);
|
||||
core.xit(name, fn, timeOut);
|
||||
}
|
||||
|
||||
class SpyFunction extends gns.SpyFunction {
|
||||
SpyFunction(String name) : super(name);
|
||||
|
||||
// TODO: vsavkin move to guinness
|
||||
andReturn(value) {
|
||||
return andCallFake(([a0, a1, a2, a3, a4, a5]) => value);
|
||||
}
|
||||
void describe(name, fn) {
|
||||
testSetup();
|
||||
core.describe(name, fn);
|
||||
}
|
||||
|
||||
class SpyObject extends gns.SpyObject {
|
||||
final Map<String, SpyFunction> _spyFuncs = {};
|
||||
|
||||
SpyObject([arg]) {}
|
||||
|
||||
SpyFunction spy(String funcName) =>
|
||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||
|
||||
void prop(String funcName, value) {
|
||||
_spyFuncs
|
||||
.putIfAbsent("get:${funcName}", () => new SpyFunction(funcName))
|
||||
.andReturn(value);
|
||||
}
|
||||
|
||||
static stub([object = null, config = null, overrides = null]) {
|
||||
if (object is! SpyObject) {
|
||||
overrides = config;
|
||||
config = object;
|
||||
object = new SpyObject();
|
||||
}
|
||||
|
||||
var m = StringMapWrapper.merge(config, overrides);
|
||||
StringMapWrapper.forEach(m, (value, key) {
|
||||
object.spy(key).andReturn(value);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
void ddescribe(name, fn) {
|
||||
testSetup();
|
||||
core.ddescribe(name, fn);
|
||||
}
|
||||
|
||||
bool isInInnerZone() => Zone.current['_innerZone'] == true;
|
||||
void xdescribe(name, fn) {
|
||||
testSetup();
|
||||
core.xdescribe(name, fn);
|
||||
}
|
200
modules/angular2/src/testing/testing_internal_core.dart
Normal file
200
modules/angular2/src/testing/testing_internal_core.dart
Normal file
@ -0,0 +1,200 @@
|
||||
library angular2.src.testing.testing_internal_core;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:guinness2/guinness2.dart' as gns;
|
||||
export 'package:guinness2/guinness2.dart'
|
||||
hide
|
||||
Expect,
|
||||
expect,
|
||||
NotExpect,
|
||||
beforeEach,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
describe,
|
||||
ddescribe,
|
||||
xdescribe,
|
||||
SpyObject,
|
||||
SpyFunction;
|
||||
|
||||
export 'matchers.dart' show expect, Expect, NotExpect;
|
||||
|
||||
import 'package:angular2/src/core/reflection/reflection.dart';
|
||||
import 'package:angular2/src/core/reflection/reflection_capabilities.dart';
|
||||
|
||||
import 'package:angular2/src/core/di/provider.dart' show bind;
|
||||
import 'package:angular2/src/facade/collection.dart' show StringMapWrapper;
|
||||
|
||||
import 'test_injector.dart';
|
||||
export 'test_injector.dart' show inject;
|
||||
|
||||
TestInjector _testInjector = getTestInjector();
|
||||
bool _isCurrentTestAsync;
|
||||
Future _currentTestFuture;
|
||||
bool _inIt = false;
|
||||
bool _initialized = false;
|
||||
List<dynamic> _platformProviders = [];
|
||||
List<dynamic> _applicationProviders = [];
|
||||
|
||||
class AsyncTestCompleter {
|
||||
final _completer = new Completer();
|
||||
|
||||
AsyncTestCompleter() {
|
||||
_currentTestFuture = this.future;
|
||||
}
|
||||
|
||||
void done() {
|
||||
_completer.complete();
|
||||
}
|
||||
|
||||
Future get future => _completer.future;
|
||||
}
|
||||
|
||||
void setDartBaseTestProviders(List<dynamic> platform, List<dynamic> application) {
|
||||
_platformProviders = platform;
|
||||
_applicationProviders = application;
|
||||
}
|
||||
|
||||
void testSetup() {
|
||||
if (_initialized) {
|
||||
return;
|
||||
}
|
||||
_initialized = true;
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
setBaseTestProviders(_platformProviders, _applicationProviders);
|
||||
// beforeEach configuration:
|
||||
// - clear the bindings before each test,
|
||||
// - collect the bindings before each test, see beforeEachProviders(),
|
||||
// - create the test injector to be used in beforeEach() and it()
|
||||
|
||||
gns.beforeEach(() {
|
||||
_testInjector.reset();
|
||||
_currentTestFuture = null;
|
||||
});
|
||||
|
||||
var completerProvider = bind(AsyncTestCompleter).toFactory(() {
|
||||
// Mark the test as async when an AsyncTestCompleter is injected in an it(),
|
||||
if (!_inIt) throw 'AsyncTestCompleter can only be injected in an "it()"';
|
||||
_isCurrentTestAsync = true;
|
||||
return new AsyncTestCompleter();
|
||||
});
|
||||
|
||||
gns.beforeEach(() {
|
||||
_isCurrentTestAsync = false;
|
||||
_testInjector.addProviders([completerProvider]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows overriding default providers defined in test_injector.js.
|
||||
*
|
||||
* The given function must return a list of DI providers.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* beforeEachProviders(() => [
|
||||
* bind(Compiler).toClass(MockCompiler),
|
||||
* bind(SomeToken).toValue(myValue),
|
||||
* ]);
|
||||
*/
|
||||
void beforeEachProviders(Function fn) {
|
||||
testSetup();
|
||||
gns.beforeEach(() {
|
||||
var providers = fn();
|
||||
if (providers != null) _testInjector.addProviders(providers);
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated('using beforeEachProviders instead')
|
||||
void beforeEachBindings(Function fn) {
|
||||
beforeEachProviders(fn);
|
||||
}
|
||||
|
||||
void beforeEach(fn) {
|
||||
testSetup();
|
||||
if (fn is! FunctionWithParamTokens) fn =
|
||||
new FunctionWithParamTokens([], fn, false);
|
||||
gns.beforeEach(() {
|
||||
_testInjector.execute(fn);
|
||||
});
|
||||
}
|
||||
|
||||
void _it(gnsFn, name, fn) {
|
||||
testSetup();
|
||||
if (fn is! FunctionWithParamTokens) fn =
|
||||
new FunctionWithParamTokens([], fn, false);
|
||||
gnsFn(name, () {
|
||||
_inIt = true;
|
||||
_testInjector.execute(fn);
|
||||
_inIt = false;
|
||||
if (_isCurrentTestAsync) return _currentTestFuture;
|
||||
});
|
||||
}
|
||||
|
||||
void it(name, fn, [timeOut = null]) {
|
||||
_it(gns.it, name, fn);
|
||||
}
|
||||
|
||||
void iit(name, fn, [timeOut = null]) {
|
||||
_it(gns.iit, name, fn);
|
||||
}
|
||||
|
||||
void xit(name, fn, [timeOut = null]) {
|
||||
_it(gns.xit, name, fn);
|
||||
}
|
||||
|
||||
void describe(name, fn) {
|
||||
testSetup();
|
||||
gns.describe(name, fn);
|
||||
}
|
||||
|
||||
void ddescribe(name, fn) {
|
||||
testSetup();
|
||||
gns.ddescribe(name, fn);
|
||||
}
|
||||
|
||||
void xdescribe(name, fn) {
|
||||
testSetup();
|
||||
gns.xdescribe(name, fn);
|
||||
}
|
||||
|
||||
class SpyFunction extends gns.SpyFunction {
|
||||
SpyFunction(String name) : super(name);
|
||||
|
||||
// TODO: vsavkin move to guinness
|
||||
andReturn(value) {
|
||||
return andCallFake(([a0, a1, a2, a3, a4, a5]) => value);
|
||||
}
|
||||
}
|
||||
|
||||
class SpyObject extends gns.SpyObject {
|
||||
final Map<String, SpyFunction> _spyFuncs = {};
|
||||
|
||||
SpyObject([arg]) {}
|
||||
|
||||
SpyFunction spy(String funcName) =>
|
||||
_spyFuncs.putIfAbsent(funcName, () => new SpyFunction(funcName));
|
||||
|
||||
void prop(String funcName, value) {
|
||||
_spyFuncs
|
||||
.putIfAbsent("get:${funcName}", () => new SpyFunction(funcName))
|
||||
.andReturn(value);
|
||||
}
|
||||
|
||||
static stub([object = null, config = null, overrides = null]) {
|
||||
if (object is! SpyObject) {
|
||||
overrides = config;
|
||||
config = object;
|
||||
object = new SpyObject();
|
||||
}
|
||||
|
||||
var m = StringMapWrapper.merge(config, overrides);
|
||||
StringMapWrapper.forEach(m, (value, key) {
|
||||
object.spy(key).andReturn(value);
|
||||
});
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
bool isInInnerZone() => Zone.current['_innerZone'] == true;
|
@ -13,60 +13,62 @@ import {
|
||||
import {DecimalPipe, PercentPipe, CurrencyPipe} from 'angular2/common';
|
||||
|
||||
export function main() {
|
||||
// TODO(mlaval): enable tests when Intl API is no longer used, see
|
||||
// https://github.com/angular/angular/issues/3333
|
||||
if (browserDetection.supportsIntlApi) {
|
||||
describe("DecimalPipe", () => {
|
||||
var pipe;
|
||||
describe('Number pipes', () => {
|
||||
// TODO(mlaval): enable tests when Intl API is no longer used, see
|
||||
// https://github.com/angular/angular/issues/3333
|
||||
if (browserDetection.supportsIntlApi) {
|
||||
describe("DecimalPipe", () => {
|
||||
var pipe;
|
||||
|
||||
beforeEach(() => { pipe = new DecimalPipe(); });
|
||||
beforeEach(() => { pipe = new DecimalPipe(); });
|
||||
|
||||
describe("transform", () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(12345, [])).toEqual('12,345');
|
||||
expect(pipe.transform(123, ['.2'])).toEqual('123.00');
|
||||
expect(pipe.transform(1, ['3.'])).toEqual('001');
|
||||
expect(pipe.transform(1.1, ['3.4-5'])).toEqual('001.1000');
|
||||
describe("transform", () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(12345, [])).toEqual('12,345');
|
||||
expect(pipe.transform(123, ['.2'])).toEqual('123.00');
|
||||
expect(pipe.transform(1, ['3.'])).toEqual('001');
|
||||
expect(pipe.transform(1.1, ['3.4-5'])).toEqual('001.1000');
|
||||
|
||||
expect(pipe.transform(1.123456, ['3.4-5'])).toEqual('001.12346');
|
||||
expect(pipe.transform(1.1234, [])).toEqual('1.123');
|
||||
expect(pipe.transform(1.123456, ['3.4-5'])).toEqual('001.12346');
|
||||
expect(pipe.transform(1.1234, [])).toEqual('1.123');
|
||||
});
|
||||
|
||||
it("should not support other objects",
|
||||
() => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
|
||||
});
|
||||
|
||||
it("should not support other objects",
|
||||
() => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
|
||||
});
|
||||
});
|
||||
|
||||
describe("PercentPipe", () => {
|
||||
var pipe;
|
||||
describe("PercentPipe", () => {
|
||||
var pipe;
|
||||
|
||||
beforeEach(() => { pipe = new PercentPipe(); });
|
||||
beforeEach(() => { pipe = new PercentPipe(); });
|
||||
|
||||
describe("transform", () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(1.23, [])).toEqual('123%');
|
||||
expect(pipe.transform(1.2, ['.2'])).toEqual('120.00%');
|
||||
describe("transform", () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(1.23, [])).toEqual('123%');
|
||||
expect(pipe.transform(1.2, ['.2'])).toEqual('120.00%');
|
||||
});
|
||||
|
||||
it("should not support other objects",
|
||||
() => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
|
||||
});
|
||||
|
||||
it("should not support other objects",
|
||||
() => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
|
||||
});
|
||||
});
|
||||
|
||||
describe("CurrencyPipe", () => {
|
||||
var pipe;
|
||||
describe("CurrencyPipe", () => {
|
||||
var pipe;
|
||||
|
||||
beforeEach(() => { pipe = new CurrencyPipe(); });
|
||||
beforeEach(() => { pipe = new CurrencyPipe(); });
|
||||
|
||||
describe("transform", () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(123, [])).toEqual('USD123');
|
||||
expect(pipe.transform(12, ['EUR', false, '.2'])).toEqual('EUR12.00');
|
||||
describe("transform", () => {
|
||||
it('should return correct value for numbers', () => {
|
||||
expect(pipe.transform(123, [])).toEqual('USD123');
|
||||
expect(pipe.transform(12, ['EUR', false, '.2'])).toEqual('EUR12.00');
|
||||
});
|
||||
|
||||
it("should not support other objects",
|
||||
() => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
|
||||
});
|
||||
|
||||
it("should not support other objects",
|
||||
() => { expect(() => pipe.transform(new Object(), [])).toThrowError(); });
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -72,8 +72,7 @@ export function main() {
|
||||
inject([RuntimeMetadataResolver], (resolver: RuntimeMetadataResolver) => {
|
||||
var value: string =
|
||||
resolver.getDirectiveMetadata(ComponentWithoutModuleId).type.moduleUrl;
|
||||
var expectedEndValue =
|
||||
IS_DART ? 'base/dist/dart/angular2/test/compiler/runtime_metadata_spec.dart' : './';
|
||||
var expectedEndValue = IS_DART ? 'test/compiler/runtime_metadata_spec.dart' : './';
|
||||
expect(value.endsWith(expectedEndValue)).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
@ -50,50 +50,58 @@ import {Unparser} from '../core/change_detection/parser/unparser';
|
||||
|
||||
var expressionUnparser = new Unparser();
|
||||
|
||||
var MOCK_SCHEMA_REGISTRY = [
|
||||
provide(
|
||||
ElementSchemaRegistry,
|
||||
{useValue: new MockSchemaRegistry({'invalidProp': false}, {'mappedAttr': 'mappedProp'})})
|
||||
];
|
||||
|
||||
export function main() {
|
||||
describe('TemplateParser', () => {
|
||||
beforeEachProviders(() => [
|
||||
TEST_PROVIDERS,
|
||||
provide(ElementSchemaRegistry,
|
||||
{
|
||||
useValue: new MockSchemaRegistry({'invalidProp': false},
|
||||
{'mappedAttr': 'mappedProp'})
|
||||
})
|
||||
]);
|
||||
var ngIf;
|
||||
var parse;
|
||||
|
||||
var parser: TemplateParser;
|
||||
var ngIf;
|
||||
|
||||
beforeEach(inject([TemplateParser], (_parser) => {
|
||||
parser = _parser;
|
||||
function commonBeforeEach() {
|
||||
beforeEach(inject([TemplateParser], (parser) => {
|
||||
ngIf = CompileDirectiveMetadata.create(
|
||||
{selector: '[ngIf]', type: new CompileTypeMetadata({name: 'NgIf'}), inputs: ['ngIf']});
|
||||
|
||||
parse = (template: string, directives: CompileDirectiveMetadata[],
|
||||
pipes: CompilePipeMetadata[] = null): TemplateAst[] => {
|
||||
if (pipes === null) {
|
||||
pipes = [];
|
||||
}
|
||||
return parser.parse(template, directives, pipes, 'TestComp');
|
||||
};
|
||||
}));
|
||||
}
|
||||
|
||||
function parse(template: string, directives: CompileDirectiveMetadata[],
|
||||
pipes: CompilePipeMetadata[] = null): TemplateAst[] {
|
||||
if (pipes === null) {
|
||||
pipes = [];
|
||||
}
|
||||
return parser.parse(template, directives, pipes, 'TestComp');
|
||||
}
|
||||
describe('TemplateParser template transform', () => {
|
||||
beforeEachProviders(() => [TEST_PROVIDERS, MOCK_SCHEMA_REGISTRY]);
|
||||
|
||||
describe('template transform', () => {
|
||||
beforeEachProviders(
|
||||
() => [provide(TEMPLATE_TRANSFORMS, {useValue: new FooAstTransformer(), multi: true})]);
|
||||
beforeEachProviders(
|
||||
() => [provide(TEMPLATE_TRANSFORMS, {useValue: new FooAstTransformer(), multi: true})]);
|
||||
|
||||
describe('single', () => {
|
||||
commonBeforeEach();
|
||||
it('should transform TemplateAST',
|
||||
() => { expect(humanizeTplAst(parse('<div>', []))).toEqual([[ElementAst, 'foo']]); });
|
||||
|
||||
describe('multiple', () => {
|
||||
beforeEachProviders(
|
||||
() => [provide(TEMPLATE_TRANSFORMS, {useValue: new BarAstTransformer(), multi: true})]);
|
||||
|
||||
it('should compose transformers',
|
||||
() => { expect(humanizeTplAst(parse('<div>', []))).toEqual([[ElementAst, 'bar']]); });
|
||||
});
|
||||
});
|
||||
|
||||
describe('multiple', () => {
|
||||
beforeEachProviders(
|
||||
() => [provide(TEMPLATE_TRANSFORMS, {useValue: new BarAstTransformer(), multi: true})]);
|
||||
|
||||
commonBeforeEach();
|
||||
it('should compose transformers',
|
||||
() => { expect(humanizeTplAst(parse('<div>', []))).toEqual([[ElementAst, 'bar']]); });
|
||||
});
|
||||
});
|
||||
|
||||
describe('TemplateParser', () => {
|
||||
beforeEachProviders(() => [TEST_PROVIDERS, MOCK_SCHEMA_REGISTRY]);
|
||||
|
||||
commonBeforeEach();
|
||||
|
||||
describe('parse', () => {
|
||||
describe('nodes without bindings', () => {
|
||||
|
||||
|
@ -99,7 +99,7 @@ export function main() {
|
||||
DOM.removeChild(headEl, baseEl);
|
||||
DOM.resetBaseElement();
|
||||
|
||||
expect(baseHref).toEqual('/base');
|
||||
expect(baseHref.endsWith('/base')).toBe(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
library angular2.dom.html5lib_adapter.test;
|
||||
|
||||
import 'package:guinness/guinness.dart';
|
||||
import 'package:unittest/unittest.dart' hide expect;
|
||||
import 'package:guinness2/guinness2.dart';
|
||||
import 'package:test/test.dart' hide expect;
|
||||
import 'package:angular2/src/platform/server/html_adapter.dart';
|
||||
|
||||
// A smoke-test of the adapter. It is primarily tested by the compiler.
|
||||
|
@ -263,7 +263,7 @@ export function main() {
|
||||
describe("importUri", () => {
|
||||
it("should return the importUri for a type", () => {
|
||||
expect(reflector.importUri(TestObjWith00Args)
|
||||
.endsWith('base/dist/dart/angular2/test/core/reflection/reflector_spec.dart'))
|
||||
.endsWith('test/core/reflection/reflector_spec.dart'))
|
||||
.toBe(true);
|
||||
});
|
||||
});
|
||||
|
@ -12,12 +12,21 @@ import {
|
||||
|
||||
import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';
|
||||
import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {IS_DART} from 'angular2/src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe('XHRImpl', () => {
|
||||
var xhr: XHRImpl;
|
||||
var url200 = '/base/modules/angular2/test/platform/browser/static_assets/200.html';
|
||||
var url404 = '/base/modules/angular2/test/platform/browser/static_assets/404.html';
|
||||
|
||||
// TODO(juliemr): This file currently won't work with dart unit tests run using
|
||||
// exclusive it or describe (iit or ddescribe). This is because when
|
||||
// pub run test is executed against this specific file the relative paths
|
||||
// will be relative to here, so url200 should look like
|
||||
// static_assets/200.html.
|
||||
// We currently have no way of detecting this.
|
||||
var urlBase = IS_DART ? '' : '/base/modules/angular2/';
|
||||
var url200 = urlBase + 'test/platform/browser/static_assets/200.html';
|
||||
var url404 = '/bad/path/404.html';
|
||||
|
||||
beforeEach(() => { xhr = new XHRImpl(); });
|
||||
|
||||
|
@ -18,10 +18,10 @@ import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
export function main() {
|
||||
var domEventPlugin;
|
||||
|
||||
beforeEach(() => { domEventPlugin = new DomEventsPlugin(); });
|
||||
|
||||
describe('EventManager', () => {
|
||||
|
||||
beforeEach(() => { domEventPlugin = new DomEventsPlugin(); });
|
||||
|
||||
it('should delegate event bindings to plugins that are passed in from the most generic one to the most specific one',
|
||||
() => {
|
||||
var element = el('<div></div>');
|
||||
|
@ -4,25 +4,34 @@ import {
|
||||
describeWith,
|
||||
describeWithout,
|
||||
describeWithAndWithout,
|
||||
itShouldRoute
|
||||
itShouldRoute,
|
||||
TEST_ROUTER_PROVIDERS
|
||||
} from './util';
|
||||
|
||||
import {beforeEachProviders, describe} from 'angular2/testing_internal';
|
||||
|
||||
import {registerSpecs} from './impl/async_route_spec_impl';
|
||||
|
||||
export function main() {
|
||||
registerSpecs();
|
||||
describe('async route spec', () => {
|
||||
|
||||
describeRouter('async routes', () => {
|
||||
describeWithout('children', () => {
|
||||
describeWith('route data', itShouldRoute);
|
||||
describeWithAndWithout('params', itShouldRoute);
|
||||
});
|
||||
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
|
||||
|
||||
describeWith('sync children',
|
||||
() => { describeWithAndWithout('default routes', itShouldRoute); });
|
||||
registerSpecs();
|
||||
|
||||
describeWith('async children', () => {
|
||||
describeWithAndWithout('params', () => { describeWithout('default routes', itShouldRoute); });
|
||||
describeRouter('async routes', () => {
|
||||
describeWithout('children', () => {
|
||||
describeWith('route data', itShouldRoute);
|
||||
describeWithAndWithout('params', itShouldRoute);
|
||||
});
|
||||
|
||||
describeWith('sync children',
|
||||
() => { describeWithAndWithout('default routes', itShouldRoute); });
|
||||
|
||||
describeWith('async children', () => {
|
||||
describeWithAndWithout('params',
|
||||
() => { describeWithout('default routes', itShouldRoute); });
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -4,16 +4,27 @@ import {
|
||||
describeWith,
|
||||
describeWithout,
|
||||
describeWithAndWithout,
|
||||
itShouldRoute
|
||||
itShouldRoute,
|
||||
TEST_ROUTER_PROVIDERS
|
||||
} from './util';
|
||||
|
||||
import {
|
||||
beforeEachProviders,
|
||||
describe,
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {registerSpecs} from './impl/aux_route_spec_impl';
|
||||
|
||||
export function main() {
|
||||
registerSpecs();
|
||||
describe('auxiliary route spec', () => {
|
||||
|
||||
describeRouter('aux routes', () => {
|
||||
itShouldRoute();
|
||||
describeWith('a primary route', itShouldRoute);
|
||||
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
|
||||
|
||||
registerSpecs();
|
||||
|
||||
describeRouter('aux routes', () => {
|
||||
itShouldRoute();
|
||||
describeWith('a primary route', itShouldRoute);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -238,7 +238,9 @@ export function main() {
|
||||
async.done();
|
||||
});
|
||||
|
||||
router.navigateByUrl('/rainbow(pony)');
|
||||
// TODO(juliemr): This isn't necessary for the test to pass - figure
|
||||
// out what's going on.
|
||||
// router.navigateByUrl('/rainbow(pony)');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
Redirect
|
||||
} from 'angular2/src/router/route_config/route_config_decorator';
|
||||
|
||||
import {specs, compile, TEST_ROUTER_PROVIDERS, clickOnElement, getHref} from '../util';
|
||||
import {specs, compile, clickOnElement, getHref} from '../util';
|
||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
function getLinkElement(rtc: ComponentFixture, linkIndex: number = 0) {
|
||||
@ -38,8 +38,6 @@ function auxRoutes() {
|
||||
var fixture: ComponentFixture;
|
||||
var rtr;
|
||||
|
||||
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
|
||||
|
||||
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
|
||||
tcb = tcBuilder;
|
||||
rtr = router;
|
||||
@ -143,8 +141,6 @@ function auxRoutesWithAPrimaryRoute() {
|
||||
var fixture: ComponentFixture;
|
||||
var rtr;
|
||||
|
||||
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
|
||||
|
||||
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
|
||||
tcb = tcBuilder;
|
||||
rtr = router;
|
||||
|
@ -4,23 +4,33 @@ import {
|
||||
describeWith,
|
||||
describeWithout,
|
||||
describeWithAndWithout,
|
||||
itShouldRoute
|
||||
itShouldRoute,
|
||||
TEST_ROUTER_PROVIDERS
|
||||
} from './util';
|
||||
|
||||
import {beforeEachProviders, describe, ddescribe} from 'angular2/testing_internal';
|
||||
|
||||
import {registerSpecs} from './impl/sync_route_spec_impl';
|
||||
|
||||
export function main() {
|
||||
registerSpecs();
|
||||
describe('sync route spec', () => {
|
||||
|
||||
describeRouter('sync routes', () => {
|
||||
describeWithout('children', () => { describeWithAndWithout('params', itShouldRoute); });
|
||||
beforeEachProviders(() => TEST_ROUTER_PROVIDERS);
|
||||
|
||||
describeWith('sync children', () => {
|
||||
describeWithout('default routes', () => { describeWithAndWithout('params', itShouldRoute); });
|
||||
describeWith('default routes', () => { describeWithout('params', itShouldRoute); });
|
||||
registerSpecs();
|
||||
|
||||
describeRouter('sync routes', () => {
|
||||
describeWithout('children', () => { describeWithAndWithout('params', itShouldRoute); });
|
||||
|
||||
describeWith('sync children', () => {
|
||||
describeWithout('default routes',
|
||||
() => { describeWithAndWithout('params', itShouldRoute); });
|
||||
describeWith('default routes', () => { describeWithout('params', itShouldRoute); });
|
||||
|
||||
});
|
||||
|
||||
describeWith('dynamic components', itShouldRoute);
|
||||
});
|
||||
|
||||
describeWith('dynamic components', itShouldRoute);
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
library angular2.test.web_workers.debug_tools.bootstrap;
|
||||
|
||||
import 'package:angular2/src/platform/server/html_adapter.dart';
|
||||
import "package:angular2/testing_internal.dart";
|
||||
import "package:angular2/src/testing/testing_internal_core.dart";
|
||||
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
|
||||
import "package:angular2/src/core/reflection/reflection.dart";
|
||||
import "package:angular2/src/platform/worker_app_common.dart"
|
||||
|
@ -2,7 +2,7 @@ library angular2.test.web_workers.debug_tools.message_bus_common;
|
||||
|
||||
import "dart:convert" show JSON;
|
||||
import "package:angular2/src/web_workers/shared/message_bus.dart";
|
||||
import "package:angular2/testing_internal.dart"
|
||||
import "package:angular2/src/testing/testing_internal_core.dart"
|
||||
show AsyncTestCompleter, expect, SpyObject;
|
||||
|
||||
var MESSAGE = const {'test': 10};
|
||||
|
@ -2,7 +2,7 @@ library angular2.test.web_workers.debug_tools.multi_client_server_message_bus;
|
||||
|
||||
import "dart:io";
|
||||
import "dart:async";
|
||||
import "package:angular2/testing_internal.dart"
|
||||
import "package:angular2/src/testing/testing_internal_core.dart"
|
||||
show
|
||||
AsyncTestCompleter,
|
||||
SpyObject,
|
||||
|
@ -2,7 +2,7 @@ library angular2.test.web_workers.debug_tools.single_client_server_message_bus;
|
||||
|
||||
import "dart:io";
|
||||
import "dart:async";
|
||||
import "package:angular2/testing_internal.dart"
|
||||
import "package:angular2/src/testing/testing_internal_core.dart"
|
||||
show
|
||||
AsyncTestCompleter,
|
||||
SpyObject,
|
||||
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
library angular2.test.web_workers.debug_tools.server_message_bus_common;
|
||||
|
||||
import "package:angular2/testing_internal.dart";
|
||||
import "package:angular2/src/testing/testing_internal_core.dart";
|
||||
import "dart:io";
|
||||
|
||||
@proxy
|
||||
|
@ -3,7 +3,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {UiArguments} from 'angular2/src/web_workers/shared/client_message_broker';
|
||||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {SpyMessageBroker} from '../worker/spies';
|
||||
import {expect} from 'angular2/testing_internal';
|
||||
import {expect} from 'angular2/src/testing/matchers';
|
||||
import {
|
||||
MessageBusSink,
|
||||
MessageBusSource,
|
||||
|
@ -102,6 +102,7 @@ export function main() {
|
||||
var domRootRenderer = uiInjector.get(DomRootRenderer);
|
||||
workerRenderStore = new RenderStore();
|
||||
return [
|
||||
Serializer,
|
||||
provide(ChangeDetectorGenConfig,
|
||||
{useValue: new ChangeDetectorGenConfig(true, true, false)}),
|
||||
provide(RenderStore, {useValue: workerRenderStore}),
|
||||
|
@ -1,7 +1,7 @@
|
||||
library web_workers.spies;
|
||||
|
||||
import 'package:angular2/src/web_workers/shared/client_message_broker.dart';
|
||||
import 'package:angular2/testing_internal.dart';
|
||||
import 'package:angular2/src/testing/testing_internal_core.dart';
|
||||
|
||||
@proxy
|
||||
class SpyMessageBroker extends SpyObject implements ClientMessageBroker {}
|
||||
|
@ -15,6 +15,6 @@ dependency_overrides:
|
||||
angular2:
|
||||
path: ../angular2
|
||||
dev_dependencies:
|
||||
guinness: '^0.1.17'
|
||||
guinness2: '0.0.4'
|
||||
transformers:
|
||||
- angular2
|
||||
|
@ -13,7 +13,10 @@ dependencies:
|
||||
stack_trace: '^1.1.1'
|
||||
webdriver: '^0.9.0'
|
||||
dev_dependencies:
|
||||
guinness: '^0.1.17'
|
||||
guinness2: '0.0.4'
|
||||
quiver: '^0.21.4'
|
||||
test: '^0.12.10'
|
||||
dependency_overrides:
|
||||
angular2:
|
||||
path: ../angular2
|
||||
matcher: '0.12.0+1'
|
||||
|
@ -7,7 +7,7 @@ dependencies:
|
||||
angular2_material: '^<%= packageJson.version %>'
|
||||
browser: '^0.10.0'
|
||||
dev_dependencies:
|
||||
guinness: '^0.1.17'
|
||||
guinness2: '0.0.5'
|
||||
benchpress:
|
||||
path: ../benchpress
|
||||
dependency_overrides:
|
||||
@ -15,6 +15,7 @@ dependency_overrides:
|
||||
path: ../angular2
|
||||
angular2_material:
|
||||
path: ../angular2_material
|
||||
matcher: '0.12.0+1'
|
||||
transformers:
|
||||
- angular2:
|
||||
platform_directives: 'package:angular2/src/common/directives.dart#CORE_DIRECTIVES'
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io' show Platform;
|
||||
import 'package:guinness/guinness.dart';
|
||||
import 'package:guinness2/guinness2.dart';
|
||||
import 'package:benchpress/benchpress.dart';
|
||||
import 'package:webdriver/webdriver.dart'
|
||||
show WebDriver, Capabilities, LogType, LogLevel, By;
|
||||
|
Reference in New Issue
Block a user