Skip to content

Commit da2f254

Browse files
chore(tslint): lint the tests
1 parent 366e073 commit da2f254

File tree

12 files changed

+42
-75
lines changed

12 files changed

+42
-75
lines changed

test/matchers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {equals} from "@uirouter/core";
1+
import { equals } from '@uirouter/core';
22
declare var testablePromise;
33

44
beforeEach(function() {
@@ -14,7 +14,7 @@ beforeEach(function() {
1414
toEqualValues: function() {
1515
return {
1616
compare: function(actual, expected) {
17-
let pass = Object.keys(expected)
17+
const pass = Object.keys(expected)
1818
.reduce((acc, key) => acc && equals(actual[key], expected[key]), true);
1919
return { pass };
2020
}
@@ -30,11 +30,11 @@ beforeEach(function() {
3030
toHaveClass: function() {
3131
return {
3232
compare: function(actual, clazz) {
33-
var classes = Array.prototype.slice.call(actual[0].classList);
34-
var pass = classes.indexOf(clazz) !== -1;
35-
var message = pass ? undefined : "Expected '" + (actual) + "' to have class '" + clazz + "'.";
33+
const classes = Array.prototype.slice.call(actual[0].classList);
34+
const pass = classes.indexOf(clazz) !== -1;
35+
const message = pass ? undefined : "Expected '" + (actual) + "' to have class '" + clazz + "'.";
3636

37-
return { pass: pass, message: message};
37+
return { pass: pass, message: message };
3838
}
3939
};
4040
}

test/ngModule/foo/foo.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export const child2 = { name: 'foo.child2', url: '/child2', component: Child2Com
1717

1818
@NgModule({
1919
declarations: [FooComponent, Child1Component, Child2Component],
20-
imports: [UIRouterModule.forChild({ states: [ foo, child1, child2 ]})],
20+
imports: [UIRouterModule.forChild({ states: [ foo, child1, child2 ] })],
2121
})
2222
export class FooModule {}
2323

2424
@NgModule({
2525
declarations: [FooComponent, Child1Component, Child2Component],
26-
imports: [UIRouterModule.forChild({ states: [ child1, child2, foo ]})],
26+
imports: [UIRouterModule.forChild({ states: [ child1, child2, foo ] })],
2727
})
2828
export class FooModuleOutOfOrder {}
2929

test/ngModule/lazyModule.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ import { NgModuleFactoryLoader, SystemJsNgModuleLoader } from '@angular/core';
66

77
declare let System;
88

9-
let futureFoo = {
9+
const futureFoo = {
1010
name: 'foo.**',
1111
url: '/foo',
1212
loadChildren: () => System.import('./foo/foo.module').then(x => x.FooModule)
1313
};
1414

15-
let futureBar = {
15+
const futureBar = {
1616
name: 'bar.**',
1717
url: '/bar',
1818
loadChildren: () => System.import('./foo/foo.module').then(x => x.FooModule)
1919
};
2020

21-
let augment1 = {
21+
const augment1 = {
2222
name: 'augment1',
2323
url: '/augment1',
2424
loadChildren: () => System.import('./augment/augment.module').then(x => x.AugmentModule)
2525
};
2626

27-
let augment2 = {
27+
const augment2 = {
2828
name: 'augment1.augment2',
2929
url: '/augment2',
3030
};
@@ -35,7 +35,7 @@ function configFn(router: UIRouter) {
3535

3636
describe('lazy loading', () => {
3737
beforeEach(() => {
38-
let routerModule = UIRouterModule.forRoot({ useHash: true, states: [], config: configFn });
38+
const routerModule = UIRouterModule.forRoot({ useHash: true, states: [], config: configFn });
3939

4040
TestBed.configureTestingModule({
4141
declarations: [],
@@ -47,7 +47,7 @@ describe('lazy loading', () => {
4747
});
4848

4949
it('should lazy load a module', async(inject([UIRouter], (router: UIRouter) => {
50-
let { stateRegistry, stateService, globals } = router;
50+
const { stateRegistry, stateService, globals } = router;
5151
stateRegistry.register(futureFoo);
5252

5353
const fixture = TestBed.createComponent(UIView);
@@ -68,14 +68,14 @@ describe('lazy loading', () => {
6868
})));
6969

7070
it('should throw if no future state replacement is lazy loaded', async(inject([UIRouter], (router: UIRouter) => {
71-
let { stateRegistry, stateService } = router;
71+
const { stateRegistry, stateService } = router;
7272
stateService.defaultErrorHandler(() => null);
7373
stateRegistry.register(futureBar);
7474

7575
const fixture = TestBed.createComponent(UIView);
7676
fixture.detectChanges();
7777

78-
let names = stateRegistry.get().map(state => state.name).sort();
78+
const names = stateRegistry.get().map(state => state.name).sort();
7979
expect(names.length).toBe(2);
8080
expect(names).toEqual(['', 'bar.**']);
8181

@@ -86,21 +86,21 @@ describe('lazy loading', () => {
8686
})));
8787

8888
it('should support loadChildren on non-future state (manual state cleanup)', async(inject([UIRouter], (router: UIRouter) => {
89-
let { stateRegistry, stateService } = router;
89+
const { stateRegistry, stateService } = router;
9090
stateRegistry.register(augment1);
9191
stateRegistry.register(augment2);
9292

9393
const fixture = TestBed.createComponent(UIView);
9494
fixture.detectChanges();
9595

96-
let names = stateRegistry.get().map(state => state.name).sort();
96+
const names = stateRegistry.get().map(state => state.name).sort();
9797
expect(names).toEqual(['', 'augment1', 'augment1.augment2']);
9898

9999
const wait = (delay) => new Promise(resolve => setTimeout(resolve, delay));
100100
stateService.go('augment1.augment2').then(() => {
101101
fixture.detectChanges();
102102
expect(stateService.current.name).toBe('augment1.augment2');
103-
expect(fixture.debugElement.nativeElement.textContent.replace(/\s+/g, " ").trim()).toBe('Component 1 Component 2');
103+
expect(fixture.debugElement.nativeElement.textContent.replace(/\s+/g, ' ').trim()).toBe('Component 1 Component 2');
104104
})
105105
})));
106106

test/testUtils.ts

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { forEach, map, omit, pick } from '@uirouter/core';
2-
import { DebugElement } from "@angular/core";
3-
let stateProps = ["resolve", "resolvePolicy", "data", "template", "templateUrl", "url", "name", "params"];
2+
import { DebugElement } from '@angular/core';
3+
const stateProps = ['resolve', 'resolvePolicy', 'data', 'template', 'templateUrl', 'url', 'name', 'params'];
44

55
export function tree2Array(tree, inheritName) {
66

77
function processState(parent, state, name) {
8-
let substates = omit.apply(null, [state].concat(stateProps));
9-
let thisState = pick.apply(null, [state].concat(stateProps));
8+
const substates = omit.apply(null, [state].concat(stateProps));
9+
const thisState = pick.apply(null, [state].concat(stateProps));
1010
thisState.name = name;
1111
if (!inheritName) thisState.parent = parent;
1212

@@ -22,42 +22,9 @@ export function tree2Array(tree, inheritName) {
2222
return states;
2323
}
2424

25-
return processChildren("", tree);
26-
}
27-
28-
export function PromiseResult(promise?) {
29-
let self = this, _promise: Promise<any>;
30-
let resolve, reject, complete;
31-
32-
this.setPromise = function(promise) {
33-
if (_promise) {
34-
throw new Error("Already have with'd a promise.");
35-
}
36-
37-
let onfulfilled = (data) =>
38-
resolve = data || true;
39-
let onrejected = (err) =>
40-
reject = err || true;
41-
let done = () =>
42-
complete = true;
43-
44-
_promise = promise;
45-
_promise.then(onfulfilled)
46-
.catch(onrejected)
47-
.then(done, done);
48-
};
49-
50-
this.get = () =>
51-
({ resolve: resolve, reject: reject, complete: complete });
52-
53-
this.called = () =>
54-
map(self.get(), (val, key) => val !== undefined);
55-
56-
if (promise) {
57-
this.setPromise(promise);
58-
}
25+
return processChildren('', tree);
5926
}
6027

6128
export function clickOnElement(element: DebugElement, button = 0, metaKey = false, ctrlKey = false) {
62-
element.triggerEventHandler('click', {button, metaKey, ctrlKey});
29+
element.triggerEventHandler('click', { button, metaKey, ctrlKey });
6330
}

test/ts/typescript2.3/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { UIRouter } from '@uirouter/angular';
2-
console.log(UIRouter);
2+
console.log(UIRouter); // tslint:disable-line:no-console

test/ts/typescript2.4/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { UIRouter } from '@uirouter/angular';
2-
console.log(UIRouter);
2+
console.log(UIRouter); // tslint:disable-line:no-console

test/ts/typescript2.5/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { UIRouter } from '@uirouter/angular';
2-
console.log(UIRouter);
2+
console.log(UIRouter); // tslint:disable-line:no-console

test/ts/typescript2.6/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { UIRouter } from '@uirouter/angular';
2-
console.log(UIRouter);
2+
console.log(UIRouter); // tslint:disable-line:no-console

test/uiSref/uiSref.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { UIRouterModule } from '../../src/uiRouterNgModule';
66
import { UISref } from '../../src/directives/uiSref';
77
import { UIRouter, TargetState, TransitionOptions } from '@uirouter/core';
88
import { Subject } from 'rxjs/Subject';
9-
import { Subscription } from "rxjs/Subscription";
10-
import { clickOnElement } from "../testUtils";
9+
import { Subscription } from 'rxjs/Subscription';
10+
import { clickOnElement } from '../testUtils';
1111

1212
describe('uiSref', () => {
1313
@Component({
@@ -182,7 +182,7 @@ describe('uiSref', () => {
182182
});
183183

184184
describe('when the uiSref is empty', () => {
185-
it('should emit an empty target state event', () =>{
185+
it('should emit an empty target state event', () => {
186186
expect(logger.length).toBe(1);
187187
expect(logger[0].name()).toBeNull();
188188
});

test/uiSrefStatus/uiSrefStatus.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { By } from '@angular/platform-browser';
44

55
import { SrefStatus, UISrefStatus } from '../../src/directives/uiSrefStatus';
66
import { UIRouterModule } from '../../src/uiRouterNgModule';
7-
import { clickOnElement } from "../testUtils";
7+
import { clickOnElement } from '../testUtils';
88

99
describe('uiSrefStatus', () => {
1010
@Component({

0 commit comments

Comments
 (0)