Skip to content

Commit a949034

Browse files
committedJul 13, 2017
Updates to style and functionality
1 parent 846a7a6 commit a949034

16 files changed

+38
-31
lines changed
 

‎src/app/app.component.router.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ describe('AppComponent & RouterTestingModule', () => {
7777
});
7878

7979
// Can't navigate to lazy loaded modules with this technique
80-
it('should navigate to "Heroes" on click', async function () {
81-
this.skip('lazy loaded navigation doesn\'t work');
80+
it('should navigate to "Heroes" on click', async (test) => {
81+
test.skip(`lazy loaded navigation doesn't work`);
8282

8383
await createComponent();
8484
click(page.heroesLinkDe);

‎src/app/bag/bag.spec.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('TestBed Component Tests', () => {
115115
beforeEach(async () => {
116116
await TestBed
117117
.configureTestingModule({
118-
imports: [BagModule],
118+
imports: [BagModule]
119119
})
120120
// Compile everything in BagModule
121121
.compileComponents()
@@ -323,7 +323,7 @@ describe('TestBed Component Tests', () => {
323323
expect(el.classes['open'], 'open class').to.be.false;
324324

325325
expect(el.styles['color']).to.equal(comp.color, 'color style');
326-
expect(el.styles['width']).to.equal(comp.width + 'px', 'width style');
326+
expect(el.styles['width']).to.equal(`${comp.width}px`, 'width style');
327327

328328
// Removed on 12/02/2016 when ceased public discussion of the `Renderer`. Revive in future?
329329
// expect(el.properties['customProperty'], 'customProperty').to.be.true;
@@ -338,7 +338,7 @@ describe('TestBed Component Overrides:', () => {
338338
it('should override ChildComp\'s template', () => {
339339

340340
const fixture = TestBed.configureTestingModule({
341-
declarations: [Child1Component],
341+
declarations: [Child1Component]
342342
})
343343
.overrideComponent(Child1Component, {
344344
set: { template: '<span>Fake</span>' }
@@ -352,11 +352,11 @@ describe('TestBed Component Overrides:', () => {
352352

353353
it('should override TestProvidersComp\'s FancyService provider', () => {
354354
const fixture = TestBed.configureTestingModule({
355-
declarations: [TestProvidersComponent],
355+
declarations: [TestProvidersComponent]
356356
})
357357
.overrideComponent(TestProvidersComponent, {
358358
remove: { providers: [FancyService]},
359-
add: { providers: [{ provide: FancyService, useClass: FakeFancyService }] },
359+
add: { providers: [{ provide: FancyService, useClass: FakeFancyService }] }
360360

361361
// Or replace them all (this component has only one provider)
362362
// set: { providers: [{ provide: FancyService, useClass: FakeFancyService }] },
@@ -376,7 +376,7 @@ describe('TestBed Component Overrides:', () => {
376376

377377
it('should override TestViewProvidersComp\'s FancyService viewProvider', () => {
378378
const fixture = TestBed.configureTestingModule({
379-
declarations: [TestViewProvidersComponent],
379+
declarations: [TestViewProvidersComponent]
380380
})
381381
.overrideComponent(TestViewProvidersComponent, {
382382
// remove: { viewProviders: [FancyService]},
@@ -430,7 +430,10 @@ describe('TestBed Component Overrides:', () => {
430430

431431
it('can access template local variables as references', () => {
432432
const fixture = TestBed.configureTestingModule({
433-
declarations: [ShellComponent, NeedsContentComponent, Child1Component, Child2Component, Child3Component],
433+
declarations: [
434+
ShellComponent, NeedsContentComponent, Child1Component,
435+
Child2Component, Child3Component
436+
]
434437
})
435438
.overrideComponent(ShellComponent, {
436439
set: {

‎src/app/components/banner-inline.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('BannerComponent (inline template)', () => {
1616

1717
beforeEach(() => {
1818
TestBed.configureTestingModule({
19-
declarations: [ BannerComponent ], // declare the test component
19+
declarations: [ BannerComponent ] // declare the test component
2020
});
2121

2222
fixture = TestBed.createComponent(BannerComponent);

‎src/app/components/banner.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('BannerComponent (templateUrl)', () => {
1515

1616
beforeEach(async () => {
1717
await TestBed.configureTestingModule({
18-
declarations: [ BannerComponent ], // declare the test component
18+
declarations: [ BannerComponent ] // declare the test component
1919
})
2020
.compileComponents() // compile template and css
2121
;

‎src/app/components/dashboard/dashboard-hero.component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('DashboardHeroComponent when tested directly', () => {
2020

2121
beforeEach(async () => {
2222
await TestBed.configureTestingModule({
23-
declarations: [ DashboardHeroComponent ],
23+
declarations: [ DashboardHeroComponent ]
2424
})
2525
.compileComponents() // compile template and css
2626
;
@@ -58,7 +58,7 @@ describe('DashboardHeroComponent when inside a test host', () => {
5858

5959
beforeEach(async () => {
6060
await TestBed.configureTestingModule({
61-
declarations: [ DashboardHeroComponent, TestHostComponent ], // declare both
61+
declarations: [ DashboardHeroComponent, TestHostComponent ] // declare both
6262
}).compileComponents();
6363

6464
// create TestHostComponent instead of DashboardHeroComponent

‎src/app/components/dashboard/dashboard.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { DashboardComponent } from './dashboard.component';
77
import { DashboardHeroComponent } from './dashboard-hero.component';
88

99
const routes: Routes = [
10-
{ path: 'dashboard', component: DashboardComponent },
10+
{ path: 'dashboard', component: DashboardComponent }
1111
];
1212

1313
@NgModule({

‎src/app/components/hero/hero-detail.component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function heroModuleSetup() {
134134
providers: [
135135
{ provide: ActivatedRoute, useValue: activatedRoute },
136136
{ provide: HeroService, useClass: FakeHeroService },
137-
{ provide: Router, useClass: RouterStub},
137+
{ provide: Router, useClass: RouterStub}
138138
]
139139
})
140140
.compileComponents()
@@ -252,7 +252,7 @@ function formsModuleSetup() {
252252
providers: [
253253
{ provide: ActivatedRoute, useValue: activatedRoute },
254254
{ provide: HeroService, useClass: FakeHeroService },
255-
{ provide: Router, useClass: RouterStub},
255+
{ provide: Router, useClass: RouterStub}
256256
]
257257
})
258258
.compileComponents()
@@ -278,7 +278,7 @@ function sharedModuleSetup() {
278278
providers: [
279279
{ provide: ActivatedRoute, useValue: activatedRoute },
280280
{ provide: HeroService, useClass: FakeHeroService },
281-
{ provide: Router, useClass: RouterStub},
281+
{ provide: Router, useClass: RouterStub}
282282
]
283283
})
284284
.compileComponents()

‎src/app/components/welcome.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class WelcomeComponent implements OnInit {
1111

1212
ngOnInit(): void {
1313
this.welcome = this.userService.isLoggedIn ?
14-
'Welcome, ' + this.userService.user.name :
14+
`Welcome, ${this.userService.user.name}` :
1515
'Please log in.';
1616
}
1717
}

‎src/app/services/http-hero.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class HttpHeroService {
5353

5454
private extractData(res: Response) {
5555
if (res.status < 200 || res.status >= 300) {
56-
throw new Error('Bad response status: ' + res.status);
56+
throw new Error(`Bad response status: ${res.status}`);
5757
}
5858
let body = res.json();
5959
return body.data || { };

‎src/app/services/twain.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const quotes = [
1010
'It\'s not the size of the dog in the fight, it\'s the size of the fight in the dog.',
1111
'Truth is stranger than fiction, but it is because Fiction is obliged to stick to possibilities; Truth isn\'t.',
1212
'The man who does not read good books has no advantage over the man who cannot read them.',
13-
'Get your facts first, and then you can distort them as much as you please.',
13+
'Get your facts first, and then you can distort them as much as you please.'
1414
];
1515

1616
@Injectable()

‎src/app/shared/twain.component.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('TwainComponent', () => {
2424
beforeEach(() => {
2525
TestBed.configureTestingModule({
2626
declarations: [ TwainComponent ],
27-
providers: [ TwainService ],
27+
providers: [ TwainService ]
2828
});
2929

3030
fixture = TestBed.createComponent(TwainComponent);

‎src/systemjs-angular-loader.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ export function translate(load: { source: string; address: string; }) {
2828
resolvedUrl = basePath + resolvedUrl.substr(1);
2929
}
3030

31-
return 'templateUrl: "' + resolvedUrl + '"';
31+
return `templateUrl: "${resolvedUrl}"`;
3232
})
3333
.replace(stylesRegex, function(_, relativeUrls) {
3434
const urls = [];
3535
let match: RegExpExecArray;
3636

3737
while ((match = stringRegex.exec(relativeUrls)) !== null) {
3838
if (match[2].startsWith('.')) {
39-
urls.push('"' + basePath + match[2].substr(1) + '"');
39+
urls.push(`"${basePath}${match[2].substr(1)}"`);
4040
} else {
41-
urls.push('"' + match[2] + '"');
41+
urls.push(`"${match[2]}"`);
4242
}
4343
}
4444

‎src/systemjs.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SystemJS.config({
22
paths: {
3-
'npm:': SystemJS.baseURL + '../node_modules/'
3+
'npm:': `${SystemJS.baseURL}../node_modules/`
44
},
55

66
map: {

‎src/testing/chai-addons.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
const chai = intern.getPlugin('chai');
2-
import 'sinon';
3-
41
function elementText(element: any): string {
52
if (Array.isArray(element)) {
63
return element.map(elementText).join('');
@@ -21,14 +18,16 @@ function elementText(element: any): string {
2118
return element.textContent;
2219
}
2320

24-
chai.use(({ Assertion }, utils: any) => {
21+
export function addNodeText({ Assertion }: any, utils: any) {
2522
Assertion.addMethod('nodeText', function (str: string) {
2623
const obj = utils.flag(this, 'object');
2724
const text = elementText(obj);
2825

2926
new Assertion(text).to.contain(str);
3027
});
31-
});
28+
}
29+
30+
intern.getPlugin('chai').use(addNodeText);
3231

3332
declare global {
3433
namespace Chai {

‎src/testing/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function click(element: DebugElement, eventObj: any = ButtonClickEvents.l
2020

2121
export async function tick() {
2222
await new Promise(resolve => {
23-
setTimeout(resolve);
23+
setTimeout(resolve, 50);
2424
});
2525
}
2626

‎tslint.json

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"check-else",
5353
"check-whitespace"
5454
],
55+
"prefer-template": true,
5556
"quotemark": [
5657
true,
5758
"single"
@@ -60,6 +61,10 @@
6061
"semicolon": [
6162
"always"
6263
],
64+
"trailing-comma": [true, {
65+
"multiline": "never",
66+
"singleline": "never"
67+
}],
6368
"triple-equals": [
6469
true,
6570
"allow-null-check"

0 commit comments

Comments
 (0)
Please sign in to comment.