Skip to content

Commit

Permalink
chore(tslint): run tslint --fix on the typescript tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherthielen committed Jan 17, 2018
1 parent 12bc7d8 commit b95b0ca
Show file tree
Hide file tree
Showing 25 changed files with 1,475 additions and 1,475 deletions.
28 changes: 14 additions & 14 deletions test/_matchers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="./_matchers.d.ts" />

import {equals} from "../src/common/common";
import { equals } from '../src/common/common';
declare var testablePromise;

beforeEach(function() {
Expand All @@ -9,37 +9,37 @@ beforeEach(function() {
return {
compare: function(actual, expected) {
return { pass: equals(actual, expected) };
}
}
},
};
},

toEqualValues: function() {
return {
compare: function(actual, expected) {
let pass = Object.keys(expected)
const pass = Object.keys(expected)
.reduce((acc, key) => acc && equals(actual[key], expected[key]), true);
return { pass };
}
}
},
};
},

toBeResolved: () => ({
compare: actual => ({
pass: !!testablePromise(actual).$$resolved
})
pass: !!testablePromise(actual).$$resolved,
}),
}),

toHaveClass: function() {
return {
compare: function(actual, clazz) {
var classes = Array.prototype.slice.call(actual[0].classList);
var pass = classes.indexOf(clazz) !== -1;
var message = pass ? undefined : "Expected '" + (actual) + "' to have class '" + clazz + "'.";
const classes = Array.prototype.slice.call(actual[0].classList);
const pass = classes.indexOf(clazz) !== -1;
const message = pass ? undefined : "Expected '" + (actual) + "' to have class '" + clazz + "'.";

return { pass: pass, message: message};
}
return { pass: pass, message: message };
},
};
}
},

});
});
Expand Down
20 changes: 10 additions & 10 deletions test/_testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pick, forEach, omit } from "../src/index";
import { map } from "../src/common/common";
import { pick, forEach, omit } from '../src/index';
import { map } from '../src/common/common';

let stateProps = ["resolve", "resolvePolicy", "data", "template", "templateUrl", "url", "name", "params"];
const stateProps = ['resolve', 'resolvePolicy', 'data', 'template', 'templateUrl', 'url', 'name', 'params'];

const initialUrl = document.location.href;
export const resetBrowserUrl = () =>
Expand All @@ -14,8 +14,8 @@ export const _delay = (ms) => () => delay(ms);
export function tree2Array(tree, inheritName) {

function processState(parent, state, name) {
let substates: any = omit(state, stateProps);
let thisState: any = pick(state, stateProps);
const substates: any = omit(state, stateProps);
const thisState: any = pick(state, stateProps);
thisState.name = name;
if (!inheritName) thisState.parent = parent;

Expand All @@ -31,7 +31,7 @@ export function tree2Array(tree, inheritName) {
return states;
}

return processChildren("", tree);
return processChildren('', tree);
}

export function PromiseResult(promise?) {
Expand All @@ -43,11 +43,11 @@ export function PromiseResult(promise?) {
throw new Error("Already have with'd a promise.");
}

let onfulfilled = (data) =>
const onfulfilled = (data) =>
resolve = data || true;
let onrejected = (err) =>
const onrejected = (err) =>
reject = err || true;
let done = () =>
const done = () =>
complete = true;

_promise = promise;
Expand All @@ -68,7 +68,7 @@ export function PromiseResult(promise?) {
}

export const awaitTransition = (router) => new Promise(resolve => {
let dereg = router.transitionService.onSuccess({}, (trans) => {
const dereg = router.transitionService.onSuccess({}, (trans) => {
dereg();
resolve(trans);
});
Expand Down
16 changes: 8 additions & 8 deletions test/_testingPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { UIRouter } from "../src/router";
import { UIRouterPluginBase } from "../src/interface";
import * as vanilla from "../src/vanilla";
import { UrlService } from "../src/url/urlService";
import { UIRouter } from '../src/router';
import { UIRouterPluginBase } from '../src/interface';
import * as vanilla from '../src/vanilla';
import { UrlService } from '../src/url/urlService';

export class TestingPlugin extends UIRouterPluginBase {
name: string = 'testing';
errorsCount: number = 0;
errorsThreshold: number = 1000;
name = 'testing';
errorsCount = 0;
errorsThreshold = 1000;

constructor(public router: UIRouter) {
super();
Expand All @@ -28,7 +28,7 @@ export class TestingPlugin extends UIRouterPluginBase {
}

addErrorLoopHandler() {
let $transitions = this.router.transitionService;
const $transitions = this.router.transitionService;
$transitions.onCreate({}, trans => {
trans.promise.catch(() => this.errorsCount++);
if (this.errorsCount > this.errorsThreshold) {
Expand Down
66 changes: 33 additions & 33 deletions test/commonSpec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
defaults, filter, is, eq, not, pattern, val, isInjectable
} from "../src/index";
defaults, filter, is, eq, not, pattern, val, isInjectable,
} from '../src/index';
import { map, mapObj, pick } from '../src/common/common';

describe('common', function() {
describe('filter', function() {
it("should filter arrays", function() {
var input = [ 1, 2, 3, 4, 5 ];
var filtered = filter(input, function(int) { return int > 2; });
it('should filter arrays', function() {
const input = [ 1, 2, 3, 4, 5 ];
const filtered = filter(input, function(int) { return int > 2; });
expect(filtered.length).toBe(3);
expect(filtered).toEqual([ 3, 4, 5 ]);
});
Expand All @@ -16,35 +16,35 @@ describe('common', function() {
expect(filter([0, 1, 0, 2, 0, 3, 4], function(v) { return !!v; })).toEqual([1, 2, 3, 4]);
});

it("should filter objects", function() {
var input = { foo: 1, bar: 2, baz: 3, qux: 4 };
var filtered = filter(input, function(val, key) { return val > 2; });
it('should filter objects', function() {
const input = { foo: 1, bar: 2, baz: 3, qux: 4 };
const filtered = filter(input, function(val, key) { return val > 2; });
expect(Object.keys(filtered).length).toBe(2);
expect(filtered).toEqual({ baz: 3, qux: 4 });
});
});

describe('defaults', function() {
it('should do left-associative object merge', function() {
var options = { param1: "new val" };
var result = defaults(options, {
param1: "default val",
param2: "default val 2"
const options = { param1: 'new val' };
const result = defaults(options, {
param1: 'default val',
param2: 'default val 2',
});
expect(result).toEqual({ param1: "new val", param2: "default val 2" });
expect(result).toEqual({ param1: 'new val', param2: 'default val 2' });
});

it('should whitelist keys present in default values', function() {
var options = { param1: 1, param2: 2, param3: 3 };
var result = defaults(options, {
const options = { param1: 1, param2: 2, param3: 3 };
const result = defaults(options, {
param1: 0,
param2: 0
param2: 0,
});
expect(result).toEqual({ param1: 1, param2: 2 });
});

it('should return an object when passed an empty value', function() {
var vals = { param1: 0, param2: 0 }
const vals = { param1: 0, param2: 0 };
expect(defaults(null, vals)).toEqual(vals);
expect(defaults(undefined, vals)).toEqual(vals);
});
Expand All @@ -54,7 +54,7 @@ describe('common', function() {
it('should allow double-negatives', function() {
function T() { return true; }
function F() { return false; }
function empty(): boolean { return <any> ""; }
function empty(): boolean { return <any> ''; }

expect(not(not(T))()).toBe(true);
expect(not(not(F))()).toBe(false);
Expand All @@ -64,7 +64,7 @@ describe('common', function() {

describe('val', function() {
it('should return identity', function() {
var f = function() {}, foo = {};
const f = function() {}, foo = {};
expect(val(f)()).toBe(f);
expect(val(foo)()).toBe(foo);
expect(val(true)()).toBe(true);
Expand All @@ -75,18 +75,18 @@ describe('common', function() {

describe('pattern', function() {
it('should return the result of a paired function when a condition function returns true', function() {
var typeChecker = pattern([
[is(Number), val("number!")],
[is(String), val("string!")],
[is(Boolean), val("boolean!")],
[eq(null), val("null!")]
const typeChecker = pattern([
[is(Number), val('number!')],
[is(String), val('string!')],
[is(Boolean), val('boolean!')],
[eq(null), val('null!')],
]);

expect(typeChecker(1)).toBe("number!");
expect(typeChecker("foo!")).toBe("string!");
expect(typeChecker(true)).toBe("boolean!");
expect(typeChecker(false)).toBe("boolean!");
expect(typeChecker(null)).toBe("null!");
expect(typeChecker(1)).toBe('number!');
expect(typeChecker('foo!')).toBe('string!');
expect(typeChecker(true)).toBe('boolean!');
expect(typeChecker(false)).toBe('boolean!');
expect(typeChecker(null)).toBe('null!');
expect(typeChecker(undefined)).toBe(undefined);
});
});
Expand All @@ -109,20 +109,20 @@ describe('common', function() {
});

it('should accept ng1 array notation', function() {
var fn = ['foo', 'bar', function(foo, bar) {}];
const fn = ['foo', 'bar', function(foo, bar) {}];
expect(isInjectable(fn)).toBeTruthy();
});
});

describe('pick', () => {
it('should pick inherited properties', () => {
let parent = { foo: 'foo', bar: 'bar' };
let child = Object.create(parent);
const parent = { foo: 'foo', bar: 'bar' };
const child = Object.create(parent);
expect(pick(child, ['foo'])).toEqual({ foo: 'foo' });
});

it('should not pick missing properties', () => {
let obj = { foo: 'foo', bar: 'bar' };
const obj = { foo: 'foo', bar: 'bar' };
expect(pick(obj, ['baz'])).toEqual({ });
});
});
Expand Down
12 changes: 6 additions & 6 deletions test/globSpec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {Glob} from "../src/common/glob";
import { Glob } from '../src/common/glob';

describe('Glob', function() {
it('should match exact strings', function() {
var state = 'about.person.item';
let state = 'about.person.item';

expect(new Glob('about.person.item').matches(state)).toBe(true);
expect(new Glob('about.person.item.foo').matches(state)).toBe(false);
expect(new Glob('foo.about.person.item').matches(state)).toBe(false);
});

it('with a single wildcard (*) should match a top level state', function() {
var glob = new Glob('*');
let glob = new Glob('*');

expect(glob.matches('foo')).toBe(true);
expect(glob.matches('bar')).toBe(true);
Expand All @@ -20,7 +20,7 @@ describe('Glob', function() {
});

it('with a single wildcard (*) should match any single non-empty segment', function() {
var state = 'about.person.item';
let state = 'about.person.item';

expect(new Glob('*.person.item').matches(state)).toBe(true);
expect(new Glob('*.*.item').matches(state)).toBe(true);
Expand All @@ -34,15 +34,15 @@ describe('Glob', function() {
});

it('with a double wildcard (**) should match any valid state name', function() {
var glob = new Glob('**');
let glob = new Glob('**');

expect(glob.matches('foo')).toBe(true);
expect(glob.matches('bar')).toBe(true);
expect(glob.matches('foo.bar')).toBe(true);
});

it('with a double wildcard (**) should match zero or more segments', function() {
var state = 'about.person.item';
let state = 'about.person.item';

expect(new Glob('**').matches(state)).toBe(true);
expect(new Glob('**.**').matches(state)).toBe(true);
Expand Down
Loading

0 comments on commit b95b0ca

Please sign in to comment.