style(lint): re-format modules/@angular
This commit is contained in:
@ -1,12 +1,6 @@
|
||||
import {describe, it, expect, beforeEach, ddescribe, iit, xit} from '@angular/core/testing';
|
||||
import {
|
||||
isPresent,
|
||||
RegExpWrapper,
|
||||
RegExpMatcherWrapper,
|
||||
StringWrapper,
|
||||
hasConstructor,
|
||||
resolveEnumToken
|
||||
} from '../src/lang';
|
||||
import {beforeEach, ddescribe, describe, expect, iit, it, xit} from '@angular/core/testing';
|
||||
|
||||
import {RegExpMatcherWrapper, RegExpWrapper, StringWrapper, hasConstructor, isPresent, resolveEnumToken} from '../src/lang';
|
||||
|
||||
enum UsefulEnum {
|
||||
MyToken,
|
||||
@ -36,15 +30,16 @@ 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: any /** TODO #9100 */) => `!${match[1]}!`);
|
||||
let m =
|
||||
RegExpWrapper.replaceAll(re, 'a1b2c', (match: any /** TODO #9100 */) => `!${match[1]}!`);
|
||||
expect(m).toEqual('a!1!b!2!c');
|
||||
});
|
||||
});
|
||||
@ -60,83 +55,83 @@ export function main() {
|
||||
var s: any /** TODO #9100 */;
|
||||
|
||||
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');
|
||||
|
||||
@ -146,10 +141,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