revert(format): Revert "chore(format): update to latest formatter"
This reverts commit 03627aa84d.
This commit is contained in:
@@ -1,6 +1,25 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el, SpyObject, AsyncTestCompleter, inject, browserDetection} from 'angular2/testing_internal';
|
||||
import {
|
||||
describe,
|
||||
it,
|
||||
expect,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
iit,
|
||||
xit,
|
||||
el,
|
||||
SpyObject,
|
||||
AsyncTestCompleter,
|
||||
inject,
|
||||
browserDetection
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {ObservableWrapper, Observable, Subject, EventEmitter, PromiseWrapper} from 'angular2/src/facade/async';
|
||||
import {
|
||||
ObservableWrapper,
|
||||
Observable,
|
||||
Subject,
|
||||
EventEmitter,
|
||||
PromiseWrapper
|
||||
} from 'angular2/src/facade/async';
|
||||
|
||||
export function main() {
|
||||
describe('EventEmitter', () => {
|
||||
@@ -8,7 +27,7 @@ export function main() {
|
||||
|
||||
beforeEach(() => { emitter = new EventEmitter(); });
|
||||
|
||||
it('should call the next callback', inject([AsyncTestCompleter], (async) => {
|
||||
it("should call the next callback", inject([AsyncTestCompleter], (async) => {
|
||||
ObservableWrapper.subscribe(emitter, (value) => {
|
||||
expect(value).toEqual(99);
|
||||
async.done();
|
||||
@@ -17,26 +36,26 @@ export function main() {
|
||||
ObservableWrapper.callEmit(emitter, 99);
|
||||
}));
|
||||
|
||||
it('should call the throw callback', inject([AsyncTestCompleter], (async) => {
|
||||
it("should call the throw callback", inject([AsyncTestCompleter], (async) => {
|
||||
ObservableWrapper.subscribe(emitter, (_) => {}, (error) => {
|
||||
expect(error).toEqual('Boom');
|
||||
expect(error).toEqual("Boom");
|
||||
async.done();
|
||||
});
|
||||
ObservableWrapper.callError(emitter, 'Boom');
|
||||
ObservableWrapper.callError(emitter, "Boom");
|
||||
}));
|
||||
|
||||
it('should work when no throw callback is provided', inject([AsyncTestCompleter], (async) => {
|
||||
it("should work when no throw callback is provided", inject([AsyncTestCompleter], (async) => {
|
||||
ObservableWrapper.subscribe(emitter, (_) => {}, (_) => { async.done(); });
|
||||
ObservableWrapper.callError(emitter, 'Boom');
|
||||
ObservableWrapper.callError(emitter, "Boom");
|
||||
}));
|
||||
|
||||
it('should call the return callback', inject([AsyncTestCompleter], (async) => {
|
||||
it("should call the return callback", inject([AsyncTestCompleter], (async) => {
|
||||
ObservableWrapper.subscribe(emitter, (_) => {}, (_) => {}, () => { async.done(); });
|
||||
|
||||
ObservableWrapper.callComplete(emitter);
|
||||
}));
|
||||
|
||||
it('should subscribe to the wrapper asynchronously', () => {
|
||||
it("should subscribe to the wrapper asynchronously", () => {
|
||||
var called = false;
|
||||
ObservableWrapper.subscribe(emitter, (value) => { called = true; });
|
||||
|
||||
@@ -47,19 +66,18 @@ export function main() {
|
||||
// Makes Edge to disconnect when running the full unit test campaign
|
||||
// TODO: remove when issue is solved: https://github.com/angular/angular/issues/4756
|
||||
if (!browserDetection.isEdge) {
|
||||
it('delivers next and error events asynchronously', inject([AsyncTestCompleter], (async) => {
|
||||
it("delivers next and error events asynchronously", inject([AsyncTestCompleter], (async) => {
|
||||
let log = [];
|
||||
ObservableWrapper.subscribe(
|
||||
emitter,
|
||||
(x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 5, 2]);
|
||||
},
|
||||
(err) => {
|
||||
log.push(err);
|
||||
expect(log).toEqual([1, 3, 5, 2, 4]);
|
||||
async.done();
|
||||
});
|
||||
ObservableWrapper.subscribe(emitter,
|
||||
(x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 5, 2]);
|
||||
},
|
||||
(err) => {
|
||||
log.push(err);
|
||||
expect(log).toEqual([1, 3, 5, 2, 4]);
|
||||
async.done();
|
||||
});
|
||||
log.push(1);
|
||||
ObservableWrapper.callEmit(emitter, 2);
|
||||
log.push(3);
|
||||
@@ -67,21 +85,19 @@ export function main() {
|
||||
log.push(5);
|
||||
}));
|
||||
|
||||
it('delivers next and complete events asynchronously',
|
||||
it("delivers next and complete events asynchronously",
|
||||
inject([AsyncTestCompleter], (async) => {
|
||||
let log = [];
|
||||
ObservableWrapper.subscribe(
|
||||
emitter,
|
||||
(x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 5, 2]);
|
||||
},
|
||||
null,
|
||||
() => {
|
||||
log.push(4);
|
||||
expect(log).toEqual([1, 3, 5, 2, 4]);
|
||||
async.done();
|
||||
});
|
||||
ObservableWrapper.subscribe(emitter,
|
||||
(x) => {
|
||||
log.push(x);
|
||||
expect(log).toEqual([1, 3, 5, 2]);
|
||||
},
|
||||
null, () => {
|
||||
log.push(4);
|
||||
expect(log).toEqual([1, 3, 5, 2, 4]);
|
||||
async.done();
|
||||
});
|
||||
log.push(1);
|
||||
ObservableWrapper.callEmit(emitter, 2);
|
||||
log.push(3);
|
||||
@@ -113,7 +129,7 @@ export function main() {
|
||||
// should call dispose on the subscription on return
|
||||
});
|
||||
|
||||
describe('ObservableWrapper', () => {
|
||||
describe("ObservableWrapper", () => {
|
||||
|
||||
it('should correctly check isObservable for EventEmitter', () => {
|
||||
var e = new EventEmitter(false);
|
||||
@@ -137,9 +153,9 @@ export function main() {
|
||||
});
|
||||
|
||||
// See ECMAScript 6 Spec 25.4.4.1
|
||||
describe('PromiseWrapper', () => {
|
||||
describe('#all', () => {
|
||||
it('should combine lists of Promises', inject([AsyncTestCompleter], (async) => {
|
||||
describe("PromiseWrapper", () => {
|
||||
describe("#all", () => {
|
||||
it("should combine lists of Promises", inject([AsyncTestCompleter], (async) => {
|
||||
var one = PromiseWrapper.completer();
|
||||
var two = PromiseWrapper.completer();
|
||||
|
||||
|
||||
@@ -47,19 +47,16 @@ export function main() {
|
||||
describe('slice', () => {
|
||||
beforeEach(() => { l = [1, 2, 3, 4]; });
|
||||
|
||||
it('should return the whole list if neither start nor end are specified', () => {
|
||||
expect(ListWrapper.slice(l)).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
it('should return the whole list if neither start nor end are specified',
|
||||
() => { expect(ListWrapper.slice(l)).toEqual([1, 2, 3, 4]); });
|
||||
|
||||
it('should return up to the end if end is not specified', () => {
|
||||
expect(ListWrapper.slice(l, 1)).toEqual([2, 3, 4]);
|
||||
});
|
||||
it('should return up to the end if end is not specified',
|
||||
() => { expect(ListWrapper.slice(l, 1)).toEqual([2, 3, 4]); });
|
||||
|
||||
it('should support negative start', () => { expect(ListWrapper.slice(l, -1)).toEqual([4]); });
|
||||
|
||||
it('should support negative end', () => {
|
||||
expect(ListWrapper.slice(l, -3, -1)).toEqual([2, 3]);
|
||||
});
|
||||
it('should support negative end',
|
||||
() => { expect(ListWrapper.slice(l, -3, -1)).toEqual([2, 3]); });
|
||||
|
||||
it('should return empty list if start is greater than end', () => {
|
||||
expect(ListWrapper.slice(l, 4, 2)).toEqual([]);
|
||||
@@ -80,17 +77,14 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('maximum', () => {
|
||||
it('should return the maximal element', () => {
|
||||
expect(ListWrapper.maximum([1, 2, 3, 4], x => x)).toEqual(4);
|
||||
});
|
||||
it('should return the maximal element',
|
||||
() => { expect(ListWrapper.maximum([1, 2, 3, 4], x => x)).toEqual(4); });
|
||||
|
||||
it('should ignore null values', () => {
|
||||
expect(ListWrapper.maximum([null, 2, 3, null], x => x)).toEqual(3);
|
||||
});
|
||||
it('should ignore null values',
|
||||
() => { expect(ListWrapper.maximum([null, 2, 3, null], x => x)).toEqual(3); });
|
||||
|
||||
it('should use the provided function to determine maximum', () => {
|
||||
expect(ListWrapper.maximum([1, 2, 3, 4], x => -x)).toEqual(1);
|
||||
});
|
||||
it('should use the provided function to determine maximum',
|
||||
() => { expect(ListWrapper.maximum([1, 2, 3, 4], x => -x)).toEqual(1); });
|
||||
|
||||
it('should return null for an empty list',
|
||||
() => { expect(ListWrapper.maximum([], x => x)).toEqual(null); });
|
||||
@@ -99,12 +93,12 @@ export function main() {
|
||||
describe('forEachWithIndex', () => {
|
||||
var l;
|
||||
|
||||
beforeEach(() => { l = ['a', 'b']; });
|
||||
beforeEach(() => { l = ["a", "b"]; });
|
||||
|
||||
it('should iterate over an array passing values and indices', () => {
|
||||
var record = [];
|
||||
ListWrapper.forEachWithIndex(l, (value, index) => record.push([value, index]));
|
||||
expect(record).toEqual([['a', 0], ['b', 1]]);
|
||||
expect(record).toEqual([["a", 0], ["b", 1]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,80 +1,92 @@
|
||||
import {AsyncTestCompleter, beforeEach, ddescribe, describe, expect, iit, inject, it, xdescribe, xit, Log} from 'angular2/testing_internal';
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xdescribe,
|
||||
xit,
|
||||
Log
|
||||
} from 'angular2/testing_internal';
|
||||
import {BaseException, WrappedException, ExceptionHandler} from 'angular2/src/facade/exceptions';
|
||||
|
||||
class _CustomException {
|
||||
context = 'some context';
|
||||
toString(): string { return 'custom'; }
|
||||
context = "some context";
|
||||
toString(): string { return "custom"; }
|
||||
}
|
||||
|
||||
export function main() {
|
||||
describe('ExceptionHandler', () => {
|
||||
it('should output exception', () => {
|
||||
var e = ExceptionHandler.exceptionToString(new BaseException('message!'));
|
||||
expect(e).toContain('message!');
|
||||
it("should output exception", () => {
|
||||
var e = ExceptionHandler.exceptionToString(new BaseException("message!"));
|
||||
expect(e).toContain("message!");
|
||||
});
|
||||
|
||||
it('should output stackTrace', () => {
|
||||
var e = ExceptionHandler.exceptionToString(new BaseException('message!'), 'stack!');
|
||||
expect(e).toContain('stack!');
|
||||
it("should output stackTrace", () => {
|
||||
var e = ExceptionHandler.exceptionToString(new BaseException("message!"), "stack!");
|
||||
expect(e).toContain("stack!");
|
||||
});
|
||||
|
||||
it('should join a long stackTrace', () => {
|
||||
it("should join a long stackTrace", () => {
|
||||
var e =
|
||||
ExceptionHandler.exceptionToString(new BaseException('message!'), ['stack1', 'stack2']);
|
||||
expect(e).toContain('stack1');
|
||||
expect(e).toContain('stack2');
|
||||
ExceptionHandler.exceptionToString(new BaseException("message!"), ["stack1", "stack2"]);
|
||||
expect(e).toContain("stack1");
|
||||
expect(e).toContain("stack2");
|
||||
});
|
||||
|
||||
it('should output reason when present', () => {
|
||||
var e = ExceptionHandler.exceptionToString(new BaseException('message!'), null, 'reason!');
|
||||
expect(e).toContain('reason!');
|
||||
it("should output reason when present", () => {
|
||||
var e = ExceptionHandler.exceptionToString(new BaseException("message!"), null, "reason!");
|
||||
expect(e).toContain("reason!");
|
||||
});
|
||||
|
||||
describe('context', () => {
|
||||
it('should print context', () => {
|
||||
describe("context", () => {
|
||||
it("should print context", () => {
|
||||
var e = ExceptionHandler.exceptionToString(
|
||||
new WrappedException('message!', null, null, 'context!'));
|
||||
expect(e).toContain('context!');
|
||||
new WrappedException("message!", null, null, "context!"));
|
||||
expect(e).toContain("context!");
|
||||
});
|
||||
|
||||
it('should print nested context', () => {
|
||||
var original = new WrappedException('message!', null, null, 'context!');
|
||||
var e = ExceptionHandler.exceptionToString(new WrappedException('message', original));
|
||||
expect(e).toContain('context!');
|
||||
it("should print nested context", () => {
|
||||
var original = new WrappedException("message!", null, null, "context!");
|
||||
var e = ExceptionHandler.exceptionToString(new WrappedException("message", original));
|
||||
expect(e).toContain("context!");
|
||||
});
|
||||
|
||||
it('should not print context when the passed-in exception is not a BaseException', () => {
|
||||
it("should not print context when the passed-in exception is not a BaseException", () => {
|
||||
var e = ExceptionHandler.exceptionToString(new _CustomException());
|
||||
expect(e).not.toContain('context');
|
||||
expect(e).not.toContain("context");
|
||||
});
|
||||
});
|
||||
|
||||
describe('original exception', () => {
|
||||
it('should print original exception message if available (original is BaseException)', () => {
|
||||
var realOriginal = new BaseException('inner');
|
||||
var original = new WrappedException('wrapped', realOriginal);
|
||||
it("should print original exception message if available (original is BaseException)", () => {
|
||||
var realOriginal = new BaseException("inner");
|
||||
var original = new WrappedException("wrapped", realOriginal);
|
||||
var e =
|
||||
ExceptionHandler.exceptionToString(new WrappedException('wrappedwrapped', original));
|
||||
expect(e).toContain('inner');
|
||||
ExceptionHandler.exceptionToString(new WrappedException("wrappedwrapped", original));
|
||||
expect(e).toContain("inner");
|
||||
});
|
||||
|
||||
it('should print original exception message if available (original is not BaseException)',
|
||||
it("should print original exception message if available (original is not BaseException)",
|
||||
() => {
|
||||
var realOriginal = new _CustomException();
|
||||
var original = new WrappedException('wrapped', realOriginal);
|
||||
var original = new WrappedException("wrapped", realOriginal);
|
||||
var e =
|
||||
ExceptionHandler.exceptionToString(new WrappedException('wrappedwrapped', original));
|
||||
expect(e).toContain('custom');
|
||||
ExceptionHandler.exceptionToString(new WrappedException("wrappedwrapped", original));
|
||||
expect(e).toContain("custom");
|
||||
});
|
||||
});
|
||||
|
||||
describe('original stack', () => {
|
||||
it('should print original stack if available', () => {
|
||||
var realOriginal = new BaseException('inner');
|
||||
var original = new WrappedException('wrapped', realOriginal, 'originalStack');
|
||||
it("should print original stack if available", () => {
|
||||
var realOriginal = new BaseException("inner");
|
||||
var original = new WrappedException("wrapped", realOriginal, "originalStack");
|
||||
var e = ExceptionHandler.exceptionToString(
|
||||
new WrappedException('wrappedwrapped', original, 'wrappedStack'));
|
||||
expect(e).toContain('originalStack');
|
||||
new WrappedException("wrappedwrapped", original, "wrappedStack"));
|
||||
expect(e).toContain("originalStack");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit, el} from 'angular2/testing_internal';
|
||||
import {isPresent, RegExpWrapper, RegExpMatcherWrapper, StringWrapper, CONST_EXPR, hasConstructor, resolveEnumToken} from 'angular2/src/facade/lang';
|
||||
import {
|
||||
isPresent,
|
||||
RegExpWrapper,
|
||||
RegExpMatcherWrapper,
|
||||
StringWrapper,
|
||||
CONST_EXPR,
|
||||
hasConstructor,
|
||||
resolveEnumToken
|
||||
} from 'angular2/src/facade/lang';
|
||||
|
||||
enum UsefulEnum {
|
||||
MyToken,
|
||||
@@ -29,13 +37,13 @@ export function main() {
|
||||
|
||||
it('should reset before it is reused', () => {
|
||||
var re = /^['"]/g;
|
||||
var str = '\'';
|
||||
var str = "'";
|
||||
expect(RegExpWrapper.test(re, str)).toEqual(true);
|
||||
// If not reset, the second attempt to test results in false
|
||||
expect(RegExpWrapper.test(re, str)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should implement replace all', () => {
|
||||
it("should implement replace all", () => {
|
||||
let re = /(\d)+/g;
|
||||
let m = RegExpWrapper.replaceAll(re, 'a1b2c', (match) => `!${match[1]}!`);
|
||||
expect(m).toEqual('a!1!b!2!c');
|
||||
@@ -53,83 +61,83 @@ export function main() {
|
||||
var s;
|
||||
|
||||
describe('slice', () => {
|
||||
beforeEach(() => { s = 'abcdefghij'; });
|
||||
beforeEach(() => { s = "abcdefghij"; });
|
||||
|
||||
it('should return the whole string if neither start nor end are specified',
|
||||
() => { expect(StringWrapper.slice(s)).toEqual('abcdefghij'); });
|
||||
() => { expect(StringWrapper.slice(s)).toEqual("abcdefghij"); });
|
||||
|
||||
it('should return up to the end if end is not specified',
|
||||
() => { expect(StringWrapper.slice(s, 1)).toEqual('bcdefghij'); });
|
||||
() => { expect(StringWrapper.slice(s, 1)).toEqual("bcdefghij"); });
|
||||
|
||||
it('should support negative start',
|
||||
() => { expect(StringWrapper.slice(s, -1)).toEqual('j'); });
|
||||
() => { expect(StringWrapper.slice(s, -1)).toEqual("j"); });
|
||||
|
||||
it('should support negative end',
|
||||
() => { expect(StringWrapper.slice(s, -3, -1)).toEqual('hi'); });
|
||||
() => { expect(StringWrapper.slice(s, -3, -1)).toEqual("hi"); });
|
||||
|
||||
it('should return empty string if start is greater than end', () => {
|
||||
expect(StringWrapper.slice(s, 4, 2)).toEqual('');
|
||||
expect(StringWrapper.slice(s, -2, -4)).toEqual('');
|
||||
expect(StringWrapper.slice(s, 4, 2)).toEqual("");
|
||||
expect(StringWrapper.slice(s, -2, -4)).toEqual("");
|
||||
});
|
||||
});
|
||||
|
||||
describe('stripLeft', () => {
|
||||
it('should strip the first character of the string if it matches the provided input', () => {
|
||||
var input = '~angular2 is amazing';
|
||||
var expectedOutput = 'angular2 is amazing';
|
||||
var input = "~angular2 is amazing";
|
||||
var expectedOutput = "angular2 is amazing";
|
||||
|
||||
expect(StringWrapper.stripLeft(input, '~')).toEqual(expectedOutput);
|
||||
expect(StringWrapper.stripLeft(input, "~")).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it('should keep stripping characters from the start until the first unmatched character',
|
||||
() => {
|
||||
var input = '#####hello';
|
||||
var expectedOutput = 'hello';
|
||||
expect(StringWrapper.stripLeft(input, '#')).toEqual(expectedOutput);
|
||||
var input = "#####hello";
|
||||
var expectedOutput = "hello";
|
||||
expect(StringWrapper.stripLeft(input, "#")).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it('should not alter the provided input if the first character does not match the provided input',
|
||||
() => {
|
||||
var input = '+angular2 is amazing';
|
||||
expect(StringWrapper.stripLeft(input, '*')).toEqual(input);
|
||||
var input = "+angular2 is amazing";
|
||||
expect(StringWrapper.stripLeft(input, "*")).toEqual(input);
|
||||
});
|
||||
|
||||
it('should not do any alterations when an empty string or null value is passed in', () => {
|
||||
expect(StringWrapper.stripLeft('', 'S')).toEqual('');
|
||||
expect(StringWrapper.stripLeft(null, 'S')).toEqual(null);
|
||||
expect(StringWrapper.stripLeft("", "S")).toEqual("");
|
||||
expect(StringWrapper.stripLeft(null, "S")).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('stripRight', () => {
|
||||
it('should strip the first character of the string if it matches the provided input', () => {
|
||||
var input = 'angular2 is amazing!';
|
||||
var expectedOutput = 'angular2 is amazing';
|
||||
var input = "angular2 is amazing!";
|
||||
var expectedOutput = "angular2 is amazing";
|
||||
|
||||
expect(StringWrapper.stripRight(input, '!')).toEqual(expectedOutput);
|
||||
expect(StringWrapper.stripRight(input, "!")).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it('should not alter the provided input if the first character does not match the provided input',
|
||||
() => {
|
||||
var input = 'angular2 is amazing+';
|
||||
var input = "angular2 is amazing+";
|
||||
|
||||
expect(StringWrapper.stripRight(input, '*')).toEqual(input);
|
||||
expect(StringWrapper.stripRight(input, "*")).toEqual(input);
|
||||
});
|
||||
|
||||
it('should keep stripping characters from the end until the first unmatched character',
|
||||
() => {
|
||||
var input = 'hi&!&&&&&';
|
||||
var expectedOutput = 'hi&!';
|
||||
expect(StringWrapper.stripRight(input, '&')).toEqual(expectedOutput);
|
||||
var input = "hi&!&&&&&";
|
||||
var expectedOutput = "hi&!";
|
||||
expect(StringWrapper.stripRight(input, "&")).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
it('should not do any alterations when an empty string or null value is passed in', () => {
|
||||
expect(StringWrapper.stripRight('', 'S')).toEqual('');
|
||||
expect(StringWrapper.stripRight(null, 'S')).toEqual(null);
|
||||
expect(StringWrapper.stripRight("", "S")).toEqual("");
|
||||
expect(StringWrapper.stripRight(null, "S")).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveEnumToken', () => {
|
||||
it('should resolve a token given an enum and index values', () => {
|
||||
it("should resolve a token given an enum and index values", () => {
|
||||
var token = UsefulEnum.MyToken;
|
||||
expect(resolveEnumToken(UsefulEnum, token)).toEqual('MyToken');
|
||||
|
||||
@@ -139,10 +147,10 @@ export function main() {
|
||||
});
|
||||
|
||||
describe('hasConstructor', () => {
|
||||
it('should be true when the type matches',
|
||||
it("should be true when the type matches",
|
||||
() => { expect(hasConstructor(new MySuperclass(), MySuperclass)).toEqual(true); });
|
||||
|
||||
it('should be false for subtypes',
|
||||
it("should be false for subtypes",
|
||||
() => { expect(hasConstructor(new MySubclass(), MySuperclass)).toEqual(false); });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user