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:
@ -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 {}
|
||||
|
Reference in New Issue
Block a user