From 4d3ca6e1b1fc46dea6b7d5e6a7dc09ea5d8d4d44 Mon Sep 17 00:00:00 2001 From: Sebastian Peischl Date: Mon, 19 Feb 2018 21:12:37 +0100 Subject: [PATCH] update dependencies and fix unit tests --- .angular-cli.json | 15 +- package.json | 141 +++++++++--------- src/app/app.component.spec.ts | 6 +- src/app/app.module.ts | 4 +- .../components/home/home.component.spec.ts | 12 +- src/polyfills.ts | 36 +++-- src/test.ts | 14 +- tsconfig.json | 2 +- tslint.json | 53 +++++-- 9 files changed, 155 insertions(+), 128 deletions(-) diff --git a/.angular-cli.json b/.angular-cli.json index 793a55c4d..d1f797b4f 100644 --- a/.angular-cli.json +++ b/.angular-cli.json @@ -22,8 +22,7 @@ "styles": [ "styles.scss" ], - "scripts": [ - ], + "scripts": [], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", @@ -38,13 +37,16 @@ }, "lint": [ { - "project": "src/tsconfig.app.json" + "project": "src/tsconfig.app.json", + "exclude": "**/node_modules/**" }, { - "project": "src/tsconfig.spec.json" + "project": "src/tsconfig.spec.json", + "exclude": "**/node_modules/**" }, { - "project": "e2e/tsconfig.e2e.json" + "project": "e2e/tsconfig.e2e.json", + "exclude": "**/node_modules/**" } ], "test": { @@ -54,7 +56,6 @@ }, "defaults": { "styleExt": "scss", - "component": { - } + "component": {} } } diff --git a/package.json b/package.json index 6ed4fc462..b619bfd93 100644 --- a/package.json +++ b/package.json @@ -38,77 +38,76 @@ }, "dependencies": {}, "devDependencies": { - "@angular/common": "5.2.5", - "@angular/compiler": "5.2.5", - "@angular/core": "5.2.5", - "@angular/forms": "5.2.5", - "@angular/http": "5.2.5", - "@angular/platform-browser": "5.2.5", - "@angular/platform-browser-dynamic": "5.2.5", - "@angular/router": "5.2.5", - "@ngx-translate/core": "9.1.1", - "@ngx-translate/http-loader": "2.0.1", - "core-js": "2.4.1", - "enhanced-resolve": "3.3.0", - "rxjs": "5.5.2", - "zone.js": "0.8.17", - "@angular/cli": "1.6.8", - "@angular/compiler-cli": "5.2.5", - "@angular/language-service": "5.2.5", - "@types/core-js": "0.9.36", - "@types/jasmine": "2.5.54", - "@types/jasminewd2": "2.0.2", - "@types/node": "7.0.7", - "autoprefixer": "8.0.0", - "circular-dependency-plugin": "4.4.0", - "codelyzer": "4.1.0", - "copy-webpack-plugin": "4.1.1", - "copyfiles": "1.2.0", - "cross-env": "5.0.5", - "css-loader": "0.28.9", - "cssnano": "3.10.0", - "electron": "1.8.2", - "electron-builder": "20.0.4", - "electron-reload": "1.2.2", - "exports-loader": "0.7.0", - "file-loader": "1.1.6", - "html-loader": "0.5.5", - "html-webpack-plugin": "2.30.1", - "istanbul-instrumenter-loader": "3.0.0", - "jasmine-core": "2.8.0", - "jasmine-spec-reporter": "4.2.1", - "json-loader": "0.5.7", - "karma": "1.7.1", - "karma-chrome-launcher": "2.2.0", - "karma-cli": "1.0.1", - "karma-coverage-istanbul-reporter": "1.3.0", - "karma-jasmine": "1.1.0", - "karma-jasmine-html-reporter": "0.2.2", - "karma-sourcemap-loader": "0.3.7", - "less-loader": "4.0.5", - "minimist": "1.2.0", - "mkdirp": "0.5.1", - "npm-run-all": "4.1.2", - "npx": "9.7.1", - "postcss-loader": "2.1.0", - "postcss-url": "7.3.0", - "postcss-custom-properties": "6.2.0", - "protractor": "5.3.0", - "raw-loader": "0.5.1", - "sass-loader": "6.0.6", - "script-loader": "0.7.2", - "source-map-loader": "0.2.3", - "style-loader": "0.20.1", - "stylus-loader": "3.0.1", - "ts-node": "4.1.0", - "tslint": "5.9.1", - "typescript": "2.6.2", - "uglifyjs-webpack-plugin": "1.1.8", - "url-loader": "0.6.2", - "webdriver-manager": "12.0.6", - "webpack": "3.11.0", - "webpack-concat-plugin": "2.4.2", - "webpack-dev-server": "2.11.1" + "@angular/cli": "~1.7.0", + "@angular/common": "^5.2.5", + "@angular/compiler": "^5.2.5", + "@angular/compiler-cli": "^5.2.5", + "@angular/core": "^5.2.5", + "@angular/forms": "^5.2.5", + "@angular/http": "^5.2.5", + "@angular/language-service": "^5.2.5", + "@angular/platform-browser": "^5.2.5", + "@angular/platform-browser-dynamic": "^5.2.5", + "@angular/router": "^5.2.5", + "@ngx-translate/core": "^9.1.1", + "@ngx-translate/http-loader": "^2.0.1", + "@types/jasmine": "~2.8.3", + "@types/jasminewd2": "^2.0.3", + "@types/node": "^9.4.6", + "autoprefixer": "^8.0.0", + "circular-dependency-plugin": "^4.4.0", + "codelyzer": "^4.1.0", + "copy-webpack-plugin": "~4.4.1", + "copyfiles": "^1.2.0", + "core-js": "^2.4.1", + "cross-env": "^5.1.3", + "css-loader": "^0.28.9", + "cssnano": "^3.10.0", + "electron": "^1.8.2", + "electron-builder": "^20.0.5", + "electron-reload": "^1.2.2", + "enhanced-resolve": "^3.4.1", + "exports-loader": "^0.7.0", + "file-loader": "^1.1.6", + "html-loader": "^0.5.5", + "html-webpack-plugin": "^2.30.1", + "istanbul-instrumenter-loader": "^3.0.0", + "jasmine-core": "~2.99.1", + "jasmine-spec-reporter": "~4.2.1", + "json-loader": "^0.5.7", + "karma": "~2.0.0", + "karma-chrome-launcher": "~2.2.0", + "karma-cli": "^1.0.1", + "karma-coverage-istanbul-reporter": "^1.4.1", + "karma-jasmine": "~1.1.1", + "karma-jasmine-html-reporter": "^0.2.2", + "karma-sourcemap-loader": "^0.3.7", + "less-loader": "^4.0.5", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "npm-run-all": "^4.1.2", + "npx": "^9.7.1", + "postcss-custom-properties": "^7.0.0", + "postcss-loader": "^2.1.0", + "postcss-url": "^7.3.0", + "protractor": "~5.3.0", + "raw-loader": "^0.5.1", + "rxjs": "^5.5.6", + "sass-loader": "^6.0.6", + "script-loader": "^0.7.2", + "source-map-loader": "^0.2.3", + "style-loader": "^0.20.2", + "stylus-loader": "^3.0.1", + "ts-node": "~4.1.0", + "tslint": "~5.9.1", + "typescript": "~2.6.2", + "uglifyjs-webpack-plugin": "^1.2.0", + "url-loader": "^0.6.2", + "webdriver-manager": "^12.0.6", + "webpack": "~3.11.0", + "webpack-concat-plugin": "^2.4.2", + "webpack-dev-server": "^2.11.1", + "zone.js": "^0.8.20" }, "license": "SEE LICENSE IN LICENSE.md" } diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index f4079ef96..d1f760e24 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -2,6 +2,7 @@ import { TestBed, async } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; import { ElectronService } from 'app/providers/electron.service'; +import { TranslateModule } from '@ngx-translate/core'; describe('AppComponent', () => { beforeEach(async(() => { @@ -12,7 +13,10 @@ describe('AppComponent', () => { providers : [ ElectronService ], - imports: [RouterTestingModule] + imports: [ + RouterTestingModule, + TranslateModule.forRoot() + ] }).compileComponents(); })); diff --git a/src/app/app.module.ts b/src/app/app.module.ts index b903723f3..d9c04f70d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,6 +1,6 @@ import 'zone.js/dist/zone-mix'; import 'reflect-metadata'; -import 'polyfills'; +import '../polyfills'; import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; @@ -15,7 +15,7 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { ElectronService } from './providers/electron.service'; -import { WebviewDirective } from 'app/directives/webview.directive'; +import { WebviewDirective } from './directives/webview.directive'; import { AppComponent } from './app.component'; import { HomeComponent } from './components/home/home.component'; diff --git a/src/app/components/home/home.component.spec.ts b/src/app/components/home/home.component.spec.ts index db6104ad4..bf24210cb 100644 --- a/src/app/components/home/home.component.spec.ts +++ b/src/app/components/home/home.component.spec.ts @@ -1,6 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HomeComponent } from './home.component'; +import { TranslateModule } from '@ngx-translate/core'; describe('HomeComponent', () => { let component: HomeComponent; @@ -8,7 +9,8 @@ describe('HomeComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ HomeComponent ] + declarations: [ HomeComponent ], + imports: [ TranslateModule.forRoot() ] }) .compileComponents(); })); @@ -23,16 +25,10 @@ describe('HomeComponent', () => { expect(component).toBeTruthy(); }); - it(`should have as title 'App works !'`, async(() => { - fixture = TestBed.createComponent(HomeComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('App works !'); - })); - it('should render title in a h1 tag', async(() => { fixture = TestBed.createComponent(HomeComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('App works !'); + expect(compiled.querySelector('h1').textContent).toContain('PAGES.HOME.TITLE'); })); }); diff --git a/src/polyfills.ts b/src/polyfills.ts index 6114d69a4..4474f2f9e 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -31,37 +31,49 @@ // import 'core-js/es6/array'; // import 'core-js/es6/regexp'; // import 'core-js/es6/map'; +// import 'core-js/es6/weak-map'; // import 'core-js/es6/set'; /** IE10 and IE11 requires the following for NgClass support on SVG elements */ // import 'classlist.js'; // Run `npm install --save classlist.js`. -/** IE10 and IE11 requires the following to support `@angular/animation`. */ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. +/** IE10 and IE11 requires the following for the Reflect API. */ +// import 'core-js/es6/reflect'; /** Evergreen browsers require these. **/ -import 'core-js/es6/reflect'; +// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. import 'core-js/es7/reflect'; -/** ALL Firefox browsers require the following to support `@angular/animation`. **/ +/** + * Required to support Web Animations `@angular/platform-browser/animations`. + * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation + **/ // import 'web-animations-js'; // Run `npm install --save web-animations-js`. +/** + * By default, zone.js will patch all possible macroTask and DomEvents + * user can disable parts of macroTask/DomEvents patch by setting following flags + */ + + // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame + // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick + // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames + /* + * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js + * with the following flag, it will bypass `zone.js` patch for IE/Edge + */ +// (window as any).__Zone_enable_cross_context_check = true; /*************************************************************************************************** - * Zone JS is required by Angular itself. + * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone-mix'; // Included with Angular CLI. +import 'zone.js/dist/zone-mix'; // Included with Angular CLI. + /*************************************************************************************************** * APPLICATION IMPORTS */ - -/** - * Date, currency, decimal and percent pipes. - * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 - */ -// import 'intl'; // Run `npm install --save intl`. diff --git a/src/test.ts b/src/test.ts index cd612eeb0..16317897b 100644 --- a/src/test.ts +++ b/src/test.ts @@ -1,24 +1,14 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files -import 'zone.js/dist/long-stack-trace-zone'; -import 'zone.js/dist/proxy.js'; -import 'zone.js/dist/sync-test'; -import 'zone.js/dist/jasmine-patch'; -import 'zone.js/dist/async-test'; -import 'zone.js/dist/fake-async-test'; +import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. -declare const __karma__: any; declare const require: any; -// Prevent Karma from running prematurely. -__karma__.loaded = function () {}; - // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule, @@ -28,5 +18,3 @@ getTestBed().initTestEnvironment( const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. context.keys().map(context); -// Finally, start Karma to run the tests. -__karma__.start(); diff --git a/tsconfig.json b/tsconfig.json index 5666e9251..9122a7700 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,7 +23,7 @@ "node_modules/@types" ], "lib": [ - "es2016", + "es2017", "dom" ] }, diff --git a/tslint.json b/tslint.json index 9113f1368..9963d6c39 100644 --- a/tslint.json +++ b/tslint.json @@ -3,6 +3,7 @@ "node_modules/codelyzer" ], "rules": { + "arrow-return-shorthand": true, "callable-types": true, "class-name": true, "comment-format": [ @@ -10,9 +11,16 @@ "check-space" ], "curly": true, + "deprecation": { + "severity": "warn" + }, "eofline": true, "forin": true, - "import-blacklist": [true, "rxjs"], + "import-blacklist": [ + true, + "rxjs", + "rxjs/Rx" + ], "import-spacing": true, "indent": [ true, @@ -27,8 +35,14 @@ "member-access": false, "member-ordering": [ true, - "static-before-instance", - "variables-before-functions" + { + "order": [ + "static-field", + "instance-field", + "static-method", + "instance-method" + ] + } ], "no-arg": true, "no-bitwise": true, @@ -42,16 +56,22 @@ ], "no-construct": true, "no-debugger": true, - "no-duplicate-variable": true, + "no-duplicate-super": true, "no-empty": false, "no-empty-interface": true, "no-eval": true, - "no-inferrable-types": [true, "ignore-params"], + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, "no-shadowed-variable": true, "no-string-literal": false, "no-string-throw": true, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, "no-unused-expression": true, "no-use-before-declare": true, "no-var-keyword": true, @@ -70,6 +90,7 @@ ], "radix": true, "semicolon": [ + true, "always" ], "triple-equals": [ @@ -86,7 +107,6 @@ "variable-declaration": "nospace" } ], - "typeof-compare": true, "unified-signatures": true, "variable-name": false, "whitespace": [ @@ -97,9 +117,19 @@ "check-separator", "check-type" ], - - "directive-selector": [true, "attribute", "app", "camelCase"], - "component-selector": [true, "element", "app", "kebab-case"], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "no-output-on-prefix": true, "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, @@ -108,9 +138,6 @@ "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "component-class-suffix": true, - "directive-class-suffix": true, - "no-access-missing-member": true, - "templates-use-public": true, - "invoke-injectable": true + "directive-class-suffix": true } }