Skip to content

Commit

Permalink
fix: code formatting, tslint errors, i18n test dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tomastrajan committed Jul 31, 2018
1 parent 527f5f1 commit 7c8c8f5
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 74 deletions.
35 changes: 10 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"rimraf": "^2.6.2",
"standard-version": "^4.2.0",
"ts-node": "~5.0.0",
"tslint": "~5.9.1",
"tslint": "~5.11.0",
"typescript": "~2.7.2",
"webpack-bundle-analyzer": "^2.11.1"
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/examples/authenticated/authenticated.component.spec.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingModule } from '@testing/utils';

import { AuthenticatedComponent } from './authenticated.component';

describe('AuthenticatedComponent', () => {
Expand All @@ -9,6 +11,7 @@ describe('AuthenticatedComponent', () => {
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [TestingModule],
declarations: [AuthenticatedComponent]
}).compileComponents();
})
Expand Down
12 changes: 2 additions & 10 deletions src/app/examples/examples/examples.component.spec.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

import { SharedModule } from '@app/shared';
import { CoreModule } from '@app/core';
import { TestingModule } from '@testing/utils';

import { ExamplesComponent } from './examples.component';

Expand All @@ -14,12 +11,7 @@ describe('ExamplesComponent', () => {
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
RouterTestingModule,
SharedModule,
CoreModule
],
imports: [TestingModule],
declarations: [ExamplesComponent]
}).compileComponents();
})
Expand Down
12 changes: 2 additions & 10 deletions src/app/examples/stock-market/stock-market.component.spec.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';

import { CoreModule } from '@app/core';
import { SharedModule } from '@app/shared';
import { TestingModule } from '@testing/utils';

import { ExamplesModule } from '../examples.module';

Expand All @@ -16,13 +14,7 @@ describe('StockMarketComponent', () => {
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
NoopAnimationsModule,
CoreModule,
SharedModule,
ExamplesModule
]
imports: [TestingModule, CoreModule, ExamplesModule]
}).compileComponents();
})
);
Expand Down
3 changes: 3 additions & 0 deletions src/app/examples/theming/child/child.component.spec.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingModule } from '@testing/utils';

import { ChildComponent } from './child.component';

describe('ChildComponent', () => {
Expand All @@ -9,6 +11,7 @@ describe('ChildComponent', () => {
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [TestingModule],
declarations: [ChildComponent]
}).compileComponents();
})
Expand Down
6 changes: 5 additions & 1 deletion src/app/examples/theming/parent/parent.component.spec.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ParentComponent } from './parent.component';
import { TestingModule } from '@testing/utils';

import { ChildComponent } from '../child/child.component';

import { ParentComponent } from './parent.component';

describe('ParentComponent', () => {
let component: ParentComponent;
let fixture: ComponentFixture<ParentComponent>;

beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [TestingModule],
declarations: [ParentComponent, ChildComponent]
}).compileComponents();
})
Expand Down
7 changes: 2 additions & 5 deletions src/app/examples/todos/todos.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {
inject
} from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Store } from '@ngrx/store';

import { SharedModule } from '@app/shared';
import { TestStore } from '@testing/utils';
import { TestStore, TestingModule } from '@testing/utils';

import { TodosComponent } from './todos.component';
import {
Expand Down Expand Up @@ -54,8 +52,7 @@ describe('TodosComponent', () => {
async(() => {
TestBed.configureTestingModule({
declarations: [TodosComponent],
imports: [NoopAnimationsModule, SharedModule],
providers: [{ provide: Store, useClass: TestStore }]
imports: [TestingModule]
}).compileComponents();
})
);
Expand Down
6 changes: 4 additions & 2 deletions src/app/settings/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ <h2>{{ 'anms.settings.general' | translate }}</h2>
<mat-form-field>
<mat-select [placeholder]="'anms.settings.general.placeholder' | translate"
[ngModel]="settings?.language"
(selectionChange)="onLanguageSelect($event)">
(selectionChange)="onLanguageSelect($event)"
name="language">
<mat-option *ngFor="let l of languages" [value]="l.value">
{{ 'anms.settings.general.language.' + l.label | translate }}
</mat-option>
Expand All @@ -30,7 +31,8 @@ <h2>{{ 'anms.settings.themes' | translate }}</h2>
<mat-form-field>
<mat-select [placeholder]="'anms.settings.themes.placeholder' | translate"
[ngModel]="settings?.theme"
(selectionChange)="onThemeSelect($event)">
(selectionChange)="onThemeSelect($event)"
name="themes">
<mat-option *ngFor="let t of themes" [value]="t.value">
{{ 'anms.settings.themes.' + t.label | translate }}
</mat-option>
Expand Down
25 changes: 12 additions & 13 deletions src/app/settings/settings/settings.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { By } from '@angular/platform-browser';
import { Store } from '@ngrx/store';
import { MatSlideToggle } from '@angular/material';
import { RouterTestingModule } from '@angular/router/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import {
async,
ComponentFixture,
TestBed,
inject
} from '@angular/core/testing';

import { SharedModule } from '@app/shared';
import { TestStore } from '@testing/utils';
import { TestingModule, TestStore } from '@testing/utils';

import { SettingsComponent } from './settings.component';
import {
Expand All @@ -28,16 +25,16 @@ describe('SettingsComponent', () => {
let store: TestStore<SettingsState>;
let dispatchSpy;

const getSelectArrow = () =>
fixture.debugElement.query(By.css('.mat-select-trigger'));
const getOptions = () => fixture.debugElement.queryAll(By.css('mat-option'));
const getThemeSelectArrow = () =>
fixture.debugElement.queryAll(By.css('.mat-select-trigger'))[1];
const getSelectOptions = () =>
fixture.debugElement.queryAll(By.css('mat-option'));

beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, RouterTestingModule, SharedModule],
declarations: [SettingsComponent],
providers: [{ provide: Store, useClass: TestStore }]
imports: [TestingModule]
}).compileComponents();
})
);
Expand All @@ -50,7 +47,8 @@ describe('SettingsComponent', () => {
autoNightMode: true,
pageAnimations: true,
pageAnimationsDisabled: false,
elementsAnimations: true
elementsAnimations: true,
language: 'en'
});
fixture = TestBed.createComponent(SettingsComponent);
component = fixture.componentInstance;
Expand All @@ -67,11 +65,11 @@ describe('SettingsComponent', () => {

it('should dispatch change theme action on theme selection', () => {
dispatchSpy = spyOn(store, 'dispatch');
getSelectArrow().triggerEventHandler('click', {});
getThemeSelectArrow().triggerEventHandler('click', {});

fixture.detectChanges();

getOptions()[1].triggerEventHandler('click', {});
getSelectOptions()[1].triggerEventHandler('click', {});

fixture.detectChanges();

Expand Down Expand Up @@ -129,7 +127,8 @@ describe('SettingsComponent', () => {
autoNightMode: true,
pageAnimations: true,
pageAnimationsDisabled: true, // change animations disabled
elementsAnimations: true
elementsAnimations: true,
language: 'en'
});
fixture.detectChanges();

Expand Down
4 changes: 2 additions & 2 deletions src/app/static/about/about.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SharedModule } from '@app/shared';
import { TestingModule } from '@testing/utils';

import { AboutComponent } from './about.component';

Expand All @@ -11,7 +11,7 @@ describe('AboutComponent', () => {
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [SharedModule],
imports: [TestingModule],
declarations: [AboutComponent]
}).compileComponents();
})
Expand Down
6 changes: 2 additions & 4 deletions src/app/static/features/features.component.spec.ts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';

import { SharedModule } from '@app/shared';
import { CoreModule } from '@app/core';
import { TestingModule } from '@testing/utils';

import { FeaturesComponent } from './features.component';

Expand All @@ -13,7 +11,7 @@ describe('FeaturesComponent', () => {
beforeEach(
async(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule, SharedModule, CoreModule],
imports: [TestingModule],
declarations: [FeaturesComponent]
}).compileComponents();
})
Expand Down
26 changes: 26 additions & 0 deletions src/testing/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '@app/shared';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { TranslateModule } from '@ngx-translate/core';
import { Store } from '@ngrx/store';
import { BehaviorSubject, Observable } from 'rxjs';
import { RouterTestingModule } from '@angular/router/testing';

export class TestStore<T> {
private state: BehaviorSubject<T> = new BehaviorSubject(undefined);
Expand All @@ -13,3 +19,23 @@ export class TestStore<T> {

dispatch(action: any) {}
}

@NgModule({
imports: [
NoopAnimationsModule,
RouterTestingModule,
SharedModule,
TranslateModule.forRoot()
],
exports: [
NoopAnimationsModule,
RouterTestingModule,
SharedModule,
TranslateModule
],
providers: [{ provide: Store, useClass: TestStore }]
})
export class TestingModule {
constructor() {
}
}
1 change: 0 additions & 1 deletion tslint.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"no-trailing-whitespace": true,
"no-unnecessary-initializer": true,
"no-unused-expression": true,
"no-unused-variable": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
Expand Down

0 comments on commit 7c8c8f5

Please sign in to comment.