mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-24 09:52:26 +00:00
build: upgrade to angular v12
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
"rules": {
|
||||
"unicorn/filename-case": "error",
|
||||
"unicorn/no-array-callback-reference": "off",
|
||||
"unicorn/prefer-object-from-entries": "off",
|
||||
"unicorn/prevent-abbreviations": [
|
||||
"error",
|
||||
{
|
||||
|
||||
28
angular.json
28
angular.json
@@ -14,12 +14,11 @@
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"aot": true,
|
||||
"outputPath": "www",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.app.json",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"assets": [
|
||||
{
|
||||
"glob": "**/*",
|
||||
@@ -49,15 +48,23 @@
|
||||
],
|
||||
"styles": [
|
||||
{
|
||||
"input": "src/theme/variables.scss"
|
||||
"input": "src/theme/variables.scss",
|
||||
"inject": true
|
||||
},
|
||||
{
|
||||
"input": "src/global.scss"
|
||||
"input": "src/global.scss",
|
||||
"inject": true
|
||||
},
|
||||
"./node_modules/leaflet/dist/leaflet.css",
|
||||
"./node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css"
|
||||
],
|
||||
"scripts": []
|
||||
"scripts": [],
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"buildOptimizer": false,
|
||||
"sourceMap": true,
|
||||
"optimization": false,
|
||||
"namedChunks": true
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
@@ -70,9 +77,7 @@
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
@@ -107,9 +112,7 @@
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
@@ -125,7 +128,8 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": ""
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
@@ -156,8 +160,8 @@
|
||||
"options": {
|
||||
"main": "src/test.ts",
|
||||
"polyfills": "src/polyfills.ts",
|
||||
"tsConfig": "src/tsconfig.spec.json",
|
||||
"karmaConfig": "src/karma.conf.js",
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"karmaConfig": "karma.conf.js",
|
||||
"styles": [],
|
||||
"scripts": [],
|
||||
"assets": [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Protractor configuration file, see link for more information
|
||||
// https://github.com/angular/protractor/blob/master/lib/config.ts
|
||||
|
||||
const { SpecReporter } = require('jasmine-spec-reporter');
|
||||
const {SpecReporter} = require('jasmine-spec-reporter');
|
||||
|
||||
exports.config = {
|
||||
allScriptsTimeout: 11000,
|
||||
@@ -29,7 +29,7 @@ exports.config = {
|
||||
},
|
||||
onPrepare() {
|
||||
require('ts-node').register({
|
||||
project: 'e2e/tsconfig.e2e.json'
|
||||
project: 'e2e/tsconfig.json'
|
||||
});
|
||||
jasmine.getEnv().addReporter(new SpecReporter({
|
||||
spec: {displayStacktrace: true}
|
||||
|
||||
@@ -1,10 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Karma configuration file, see link for more information
|
||||
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
||||
var isDocker = require('is-docker');
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
basePath: 'src',
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
17320
package-lock.json
generated
17320
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
131
package.json
131
package.json
@@ -14,7 +14,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build": "ng build",
|
||||
"build:prod": "ng build --prod",
|
||||
"build:prod": "ng build --configuration production",
|
||||
"build:fake": "ng build --configuration=fake",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
|
||||
"check-configuration": "openstapps-configuration",
|
||||
@@ -40,107 +40,106 @@
|
||||
"test": "ng test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@angular/animations": "9.1.13",
|
||||
"@angular/cdk": "12.0.0",
|
||||
"@angular/common": "9.1.13",
|
||||
"@angular/core": "9.1.13",
|
||||
"@angular/forms": "9.1.13",
|
||||
"@angular/platform-browser": "9.1.13",
|
||||
"@angular/platform-browser-dynamic": "9.1.13",
|
||||
"@angular/router": "9.1.13",
|
||||
"@asymmetrik/ngx-leaflet": "5.0.2",
|
||||
"@asymmetrik/ngx-leaflet-markercluster": "2.1.1",
|
||||
"@angular/animations": "12.2.5",
|
||||
"@angular/cdk": "12.2.5",
|
||||
"@angular/common": "12.2.5",
|
||||
"@angular/core": "12.2.5",
|
||||
"@angular/forms": "12.2.5",
|
||||
"@angular/platform-browser": "12.2.5",
|
||||
"@angular/platform-browser-dynamic": "12.2.5",
|
||||
"@angular/router": "12.2.5",
|
||||
"@asymmetrik/ngx-leaflet": "8.1.0",
|
||||
"@asymmetrik/ngx-leaflet-markercluster": "5.0.1",
|
||||
"@capacitor/core": "2.4.6",
|
||||
"@ionic-native/core": "5.29.0",
|
||||
"@ionic-native/dialogs": "5.31.1",
|
||||
"@ionic-native/diagnostic": "5.32.0",
|
||||
"@ionic-native/geolocation": "5.29.0",
|
||||
"@ionic-native/network": "5.31.1",
|
||||
"@ionic-native/splash-screen": "5.29.0",
|
||||
"@ionic-native/status-bar": "5.29.0",
|
||||
"@ionic/angular": "5.6.9",
|
||||
"@ionic/storage": "2.2.0",
|
||||
"@ionic-native/core": "5.36.0",
|
||||
"@ionic-native/diagnostic": "5.36.0",
|
||||
"@ionic-native/dialogs": "5.36.0",
|
||||
"@ionic-native/geolocation": "5.36.0",
|
||||
"@ionic-native/network": "5.36.0",
|
||||
"@ionic-native/splash-screen": "5.36.0",
|
||||
"@ionic-native/status-bar": "5.36.0",
|
||||
"@ionic/angular": "5.7.0",
|
||||
"@ionic/storage-angular": "3.0.6",
|
||||
"@ngx-translate/core": "11.0.1",
|
||||
"@ngx-translate/http-loader": "4.0.0",
|
||||
"@openstapps/api": "0.31.0",
|
||||
"@openstapps/configuration": "0.27.0",
|
||||
"@openstapps/core": "0.49.1",
|
||||
"@openstapps/api": "0.32.0",
|
||||
"@openstapps/configuration": "0.28.1",
|
||||
"@openstapps/core": "0.51.0",
|
||||
"cordova-android": "9.0.0",
|
||||
"cordova-browser": "6.0.0",
|
||||
"cordova-ios": "6.2.0",
|
||||
"cordova-plugin-androidx-adapter": "1.1.3",
|
||||
"cordova-plugin-device": "2.0.3",
|
||||
"cordova-plugin-dialogs": "2.0.2",
|
||||
"cordova.plugins.diagnostic": "6.0.3",
|
||||
"cordova-plugin-geolocation": "4.1.0",
|
||||
"cordova-plugin-ionic-keyboard": "2.2.0",
|
||||
"cordova-plugin-ionic-webview": "5.0.0",
|
||||
"cordova-plugin-network-information": "2.0.2",
|
||||
"cordova-plugin-splashscreen": "6.0.0",
|
||||
"cordova-plugin-whitelist": "1.3.4",
|
||||
"cordova.plugins.diagnostic": "6.0.3",
|
||||
"core-js": "2.6.5",
|
||||
"deepmerge": "3.3.0",
|
||||
"form-data": "2.5.0",
|
||||
"geojson": "0.5.0",
|
||||
"leaflet": "1.4.0",
|
||||
"leaflet.markercluster": "1.4.1",
|
||||
"leaflet": "1.7.1",
|
||||
"leaflet.markercluster": "1.5.1",
|
||||
"lodash-es": "4.17.21",
|
||||
"moment": "2.29.1",
|
||||
"ngx-logger": "4.1.9",
|
||||
"ngx-markdown": "9.1.1",
|
||||
"ngx-markdown": "12.0.1",
|
||||
"ngx-moment": "5.0.0",
|
||||
"opening_hours": "3.7.0",
|
||||
"rxjs": "6.6.3",
|
||||
"tslib": "1.14.1",
|
||||
"tslib": "2.0.0",
|
||||
"zone.js": "0.11.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/architect": "0.901.13",
|
||||
"@angular-devkit/build-angular": "0.901.13",
|
||||
"@angular-devkit/core": "9.1.12",
|
||||
"@angular-devkit/schematics": "9.1.12",
|
||||
"@angular-eslint/builder": "12.2.0",
|
||||
"@angular-eslint/eslint-plugin": "12.2.0",
|
||||
"@angular-eslint/eslint-plugin-template": "12.2.0",
|
||||
"@angular-eslint/schematics": "1.2.0",
|
||||
"@angular-eslint/template-parser": "1.2.0",
|
||||
"@angular/cli": "9.1.12",
|
||||
"@angular/compiler": "9.1.13",
|
||||
"@angular/compiler-cli": "9.1.13",
|
||||
"@angular/language-service": "9.1.13",
|
||||
"@compodoc/compodoc": "1.1.10",
|
||||
"@ionic/angular-toolkit": "2.3.3",
|
||||
"@angular-devkit/architect": "0.1202.5",
|
||||
"@angular-devkit/build-angular": "12.2.5",
|
||||
"@angular-devkit/core": "12.2.5",
|
||||
"@angular-devkit/schematics": "12.2.5",
|
||||
"@angular-eslint/builder": "12.4.1",
|
||||
"@angular-eslint/eslint-plugin": "12.4.1",
|
||||
"@angular-eslint/eslint-plugin-template": "12.4.1",
|
||||
"@angular-eslint/schematics": "12.4.1",
|
||||
"@angular-eslint/template-parser": "12.4.1",
|
||||
"@angular/cli": "12.2.5",
|
||||
"@angular/compiler": "12.2.5",
|
||||
"@angular/compiler-cli": "12.2.5",
|
||||
"@angular/language-service": "12.2.5",
|
||||
"@compodoc/compodoc": "1.1.14",
|
||||
"@ionic/angular-toolkit": "4.0.0",
|
||||
"@types/deepmerge": "2.2.0",
|
||||
"@types/form-data": "2.5.0",
|
||||
"@types/jasmine": "3.3.12",
|
||||
"@types/jasminewd2": "2.0.6",
|
||||
"@types/leaflet": "1.4.4",
|
||||
"@types/leaflet.markercluster": "1.0.3",
|
||||
"@types/jasmine": "3.9.1",
|
||||
"@types/jasminewd2": "2.0.10",
|
||||
"@types/leaflet": "1.7.5",
|
||||
"@types/leaflet.markercluster": "1.4.5",
|
||||
"@types/lodash-es": "4.17.4",
|
||||
"@types/node": "14.14.37",
|
||||
"@typescript-eslint/eslint-plugin": "4.3.0",
|
||||
"@typescript-eslint/parser": "4.3.0",
|
||||
"codelyzer": "5.1.2",
|
||||
"conventional-changelog-cli": "2.0.12",
|
||||
"eslint": "7.30.0",
|
||||
"@types/node": "14.17.16",
|
||||
"@typescript-eslint/eslint-plugin": "4.31.0",
|
||||
"@typescript-eslint/parser": "4.31.0",
|
||||
"conventional-changelog-cli": "2.1.1",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-prettier": "8.3.0",
|
||||
"eslint-plugin-jsdoc": "35.4.1",
|
||||
"eslint-plugin-prettier": "3.4.0",
|
||||
"eslint-plugin-unicorn": "34.0.1",
|
||||
"eslint-plugin-jsdoc": "36.1.0",
|
||||
"eslint-plugin-prettier": "4.0.0",
|
||||
"eslint-plugin-unicorn": "36.0.0",
|
||||
"is-docker": "1.1.0",
|
||||
"jasmine-core": "3.5.0",
|
||||
"jasmine-spec-reporter": "4.2.1",
|
||||
"karma": "4.4.1",
|
||||
"jasmine-core": "3.9.0",
|
||||
"jasmine-spec-reporter": "7.0.0",
|
||||
"karma": "6.3.4",
|
||||
"karma-chrome-launcher": "3.1.0",
|
||||
"karma-coverage-istanbul-reporter": "2.1.0",
|
||||
"karma-jasmine": "2.0.1",
|
||||
"karma-jasmine-html-reporter": "1.4.2",
|
||||
"karma-coverage-istanbul-reporter": "3.0.3",
|
||||
"karma-jasmine": "4.0.1",
|
||||
"karma-jasmine-html-reporter": "1.7.0",
|
||||
"karma-mocha-reporter": "2.2.5",
|
||||
"prettier": "2.3.2",
|
||||
"protractor": "5.4.2",
|
||||
"surge": "0.21.3",
|
||||
"prettier": "2.4.0",
|
||||
"protractor": "7.0.0",
|
||||
"surge": "0.23.0",
|
||||
"ts-node": "8.0.3",
|
||||
"typescript": "3.8.3"
|
||||
"typescript": "4.3.5"
|
||||
},
|
||||
"cordova": {
|
||||
"plugins": {
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
} from '@openstapps/core';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {delay, map} from 'rxjs/operators';
|
||||
import {dependencies} from '../../../package.json';
|
||||
import packageJson from '../../../package.json';
|
||||
import {facetsMock} from './data/sample-facets';
|
||||
import {SampleThings} from './data/sample-things';
|
||||
|
||||
@@ -244,7 +244,7 @@ export const sampleIndexResponse: SCIndexResponse = {
|
||||
],
|
||||
},
|
||||
backend: {
|
||||
SCVersion: dependencies['@openstapps/core'],
|
||||
SCVersion: packageJson.dependencies['@openstapps/core'],
|
||||
externalRequestTimeout: 5000,
|
||||
hiddenTypes: [
|
||||
SCThingType.DateSeries,
|
||||
|
||||
@@ -22,6 +22,6 @@ const routes: Routes = [{path: '', redirectTo: '/news', pathMatch: 'full'}];
|
||||
*/
|
||||
@NgModule({
|
||||
exports: [RouterModule],
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
imports: [RouterModule.forRoot(routes, {relativeLinkResolution: 'legacy'})],
|
||||
})
|
||||
export class AppRoutingModule {}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {async, TestBed} from '@angular/core/testing';
|
||||
import {TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import {SplashScreen} from '@ionic-native/splash-screen/ngx';
|
||||
import {StatusBar} from '@ionic-native/status-bar/ngx';
|
||||
@@ -38,41 +38,43 @@ describe('AppComponent', () => {
|
||||
let configProvider: jasmine.SpyObj<ConfigProvider>;
|
||||
let ngxLogger: jasmine.SpyObj<NGXLogger>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
|
||||
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
|
||||
platformReadySpy = Promise.resolve();
|
||||
platformSpy = jasmine.createSpyObj('Platform', {ready: platformReadySpy});
|
||||
translateServiceSpy = jasmine.createSpyObj('TranslateService', [
|
||||
'setDefaultLang',
|
||||
'use',
|
||||
]);
|
||||
thingTranslateServiceSpy = jasmine.createSpyObj('ThingTranslateService', [
|
||||
'init',
|
||||
]);
|
||||
settingsProvider = jasmine.createSpyObj('SettingsProvider', [
|
||||
'getSettingValue',
|
||||
'provideSetting',
|
||||
'setCategoriesOrder',
|
||||
]);
|
||||
configProvider = jasmine.createSpyObj('ConfigProvider', ['init']);
|
||||
ngxLogger = jasmine.createSpyObj('NGXLogger', ['log', 'error', 'warn']);
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']);
|
||||
splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']);
|
||||
platformReadySpy = Promise.resolve();
|
||||
platformSpy = jasmine.createSpyObj('Platform', {ready: platformReadySpy});
|
||||
translateServiceSpy = jasmine.createSpyObj('TranslateService', [
|
||||
'setDefaultLang',
|
||||
'use',
|
||||
]);
|
||||
thingTranslateServiceSpy = jasmine.createSpyObj('ThingTranslateService', [
|
||||
'init',
|
||||
]);
|
||||
settingsProvider = jasmine.createSpyObj('SettingsProvider', [
|
||||
'getSettingValue',
|
||||
'provideSetting',
|
||||
'setCategoriesOrder',
|
||||
]);
|
||||
configProvider = jasmine.createSpyObj('ConfigProvider', ['init']);
|
||||
ngxLogger = jasmine.createSpyObj('NGXLogger', ['log', 'error', 'warn']);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
providers: [
|
||||
{provide: StatusBar, useValue: statusBarSpy},
|
||||
{provide: SplashScreen, useValue: splashScreenSpy},
|
||||
{provide: Platform, useValue: platformSpy},
|
||||
{provide: TranslateService, useValue: translateServiceSpy},
|
||||
{provide: ThingTranslateService, useValue: thingTranslateServiceSpy},
|
||||
{provide: SettingsProvider, useValue: settingsProvider},
|
||||
{provide: ConfigProvider, useValue: configProvider},
|
||||
{provide: NGXLogger, useValue: ngxLogger},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}));
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
providers: [
|
||||
{provide: StatusBar, useValue: statusBarSpy},
|
||||
{provide: SplashScreen, useValue: splashScreenSpy},
|
||||
{provide: Platform, useValue: platformSpy},
|
||||
{provide: TranslateService, useValue: translateServiceSpy},
|
||||
{provide: ThingTranslateService, useValue: thingTranslateServiceSpy},
|
||||
{provide: SettingsProvider, useValue: settingsProvider},
|
||||
{provide: ConfigProvider, useValue: configProvider},
|
||||
{provide: NGXLogger, useValue: ngxLogger},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
WrongConfigVersionInStorage,
|
||||
} from './errors';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {dependencies} from '../../../../package.json';
|
||||
import packageJson from '../../../../package.json';
|
||||
|
||||
describe('ConfigProvider', () => {
|
||||
let configProvider: ConfigProvider;
|
||||
@@ -216,7 +216,7 @@ describe('ConfigProvider', () => {
|
||||
});
|
||||
});
|
||||
|
||||
const scVersion = dependencies['@openstapps/core'];
|
||||
const scVersion = packageJson.dependencies['@openstapps/core'];
|
||||
|
||||
const sampleIndexResponse: SCIndexResponse = {
|
||||
app: {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api/lib/client';
|
||||
import {SCAppConfiguration, SCIndexResponse} from '@openstapps/core';
|
||||
import {NGXLogger} from 'ngx-logger';
|
||||
import {dependencies} from '../../../../package.json';
|
||||
import packageJson from '../../../../package.json';
|
||||
import {environment} from '../../../environments/environment';
|
||||
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
||||
import {StorageProvider} from '../storage/storage.provider';
|
||||
@@ -63,7 +63,7 @@ export class ConfigProvider {
|
||||
/**
|
||||
* Version of the @openstapps/core package that app is using
|
||||
*/
|
||||
scVersion = dependencies['@openstapps/core'];
|
||||
scVersion = packageJson.dependencies['@openstapps/core'];
|
||||
|
||||
/**
|
||||
* Constructor, initialise api client
|
||||
|
||||
@@ -87,7 +87,6 @@ describe('DataProvider', () => {
|
||||
});
|
||||
storageProvider = TestBed.get(StorageProvider);
|
||||
dataProvider = TestBed.get(DataProvider);
|
||||
await storageProvider.deleteAll();
|
||||
});
|
||||
|
||||
it('should generate data key', async () => {
|
||||
@@ -165,6 +164,7 @@ describe('DataProvider', () => {
|
||||
);
|
||||
const response = await dataProvider.multiSearch(request);
|
||||
|
||||
// @ts-ignore
|
||||
expect(response).toEqual(responseShould);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {CUSTOM_ELEMENTS_SCHEMA, DebugElement} from '@angular/core';
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
import {ActivatedRoute, RouterModule} from '@angular/router';
|
||||
import {IonRefresher, IonTitle} from '@ionic/angular';
|
||||
import {
|
||||
@@ -29,6 +29,7 @@ import {DataProvider} from '../data.provider';
|
||||
import {DataDetailComponent} from './data-detail.component';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {Observable, of} from 'rxjs';
|
||||
import {StorageProvider} from '../../storage/storage.provider';
|
||||
|
||||
const translations: any = {data: {detail: {TITLE: 'Foo'}}};
|
||||
|
||||
@@ -62,20 +63,39 @@ describe('DataDetailComponent', () => {
|
||||
},
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterModule.forRoot([]),
|
||||
DataRoutingModule,
|
||||
DataModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {provide: TranslateLoader, useClass: TranslateFakeLoader},
|
||||
}),
|
||||
],
|
||||
providers: [{provide: ActivatedRoute, useValue: fakeActivatedRoute}],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}));
|
||||
const storageProviderSpy = jasmine.createSpyObj('StorageProvider', [
|
||||
'init',
|
||||
'get',
|
||||
'has',
|
||||
'put',
|
||||
'search',
|
||||
]);
|
||||
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterModule.forRoot([], {relativeLinkResolution: 'legacy'}),
|
||||
DataRoutingModule,
|
||||
DataModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {provide: TranslateLoader, useClass: TranslateFakeLoader},
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
provide: ActivatedRoute,
|
||||
useValue: fakeActivatedRoute,
|
||||
},
|
||||
{
|
||||
provide: StorageProvider,
|
||||
useValue: storageProviderSpy,
|
||||
},
|
||||
],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
beforeEach(async () => {
|
||||
dataProvider = TestBed.get(DataProvider);
|
||||
@@ -90,15 +110,12 @@ describe('DataDetailComponent', () => {
|
||||
detailPage = fixture.debugElement;
|
||||
translateService.use('foo');
|
||||
fixture.detectChanges();
|
||||
await dataProvider.deleteAll();
|
||||
});
|
||||
|
||||
it('should create component', () => expect(comp).toBeDefined());
|
||||
|
||||
it('should have appropriate title', async () => {
|
||||
const title: DebugElement | null = detailPage.query(By.directive(IonTitle));
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
expect(title).not.toBe(null);
|
||||
const title: DebugElement = detailPage.query(By.directive(IonTitle));
|
||||
expect(title!.nativeElement.textContent).toBe('Foo');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
|
||||
|
||||
import {DataListComponent} from './data-list.component';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
@@ -10,17 +10,19 @@ describe('DataListComponent', () => {
|
||||
let fixture: ComponentFixture<DataListComponent>;
|
||||
let configProviderMock: jasmine.SpyObj<ConfigProvider>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', {
|
||||
getValue: () => Promise.resolve({lat: 123, lng: 123}),
|
||||
});
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DataListComponent],
|
||||
imports: [TranslateModule.forRoot()],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
providers: [{provide: ConfigProvider, useValue: configProviderMock}],
|
||||
}).compileComponents();
|
||||
}));
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', {
|
||||
getValue: () => Promise.resolve({lat: 123, lng: 123}),
|
||||
});
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DataListComponent],
|
||||
imports: [TranslateModule.forRoot()],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
providers: [{provide: ConfigProvider, useValue: configProviderMock}],
|
||||
}).compileComponents();
|
||||
}),
|
||||
);
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DataListComponent);
|
||||
|
||||
@@ -24,7 +24,6 @@ import {Point, Polygon} from 'geojson';
|
||||
import {divIcon, geoJSON, icon, LatLng, Map, marker, Marker} from 'leaflet';
|
||||
import {DataProvider} from '../data/data.provider';
|
||||
import {MapPosition, PositionService} from './position.service';
|
||||
import Timeout = NodeJS.Timeout;
|
||||
|
||||
/**
|
||||
* Provides methods for presenting the map
|
||||
@@ -91,7 +90,7 @@ export class MapProvider {
|
||||
static invalidateWhenRendered = (
|
||||
map: Map,
|
||||
element: ElementRef,
|
||||
interval: Timeout,
|
||||
interval: number,
|
||||
) => {
|
||||
if (element.nativeElement.offsetWidth === 0) {
|
||||
return;
|
||||
|
||||
@@ -50,7 +50,6 @@ import {
|
||||
} from '../position.service';
|
||||
import {MapListModalComponent} from './modals/map-list-modal.component';
|
||||
import {MapSingleModalComponent} from './modals/map-single-modal.component';
|
||||
import Timeout = NodeJS.Timeout;
|
||||
|
||||
/**
|
||||
* The main page of the map
|
||||
@@ -324,7 +323,7 @@ export class MapPageComponent {
|
||||
*/
|
||||
async onMapReady(map: Map) {
|
||||
this.map = map;
|
||||
const interval: Timeout = setInterval(() =>
|
||||
const interval = window.setInterval(() =>
|
||||
MapProvider.invalidateWhenRendered(map, this.mapContainer, interval),
|
||||
);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import {Component, ElementRef, Input, OnInit, ViewChild} from '@angular/core';
|
||||
import {SCPlace} from '@openstapps/core';
|
||||
import {geoJSON, Map, MapOptions, tileLayer} from 'leaflet';
|
||||
import {MapProvider} from '../map.provider';
|
||||
import Timeout = NodeJS.Timeout;
|
||||
|
||||
/**
|
||||
* The map widget (needs a container with explicit size)
|
||||
@@ -77,7 +76,7 @@ export class MapWidgetComponent implements OnInit {
|
||||
*/
|
||||
onMapReady(map: Map) {
|
||||
this.map = map;
|
||||
const interval: Timeout = setInterval(() => {
|
||||
const interval = window.setInterval(() => {
|
||||
MapProvider.invalidateWhenRendered(map, this.mapContainer, interval);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ describe('ContextMenuComponent', async () => {
|
||||
TranslateModule.forRoot(),
|
||||
CommonModule,
|
||||
SettingsModule,
|
||||
RouterModule.forRoot([]),
|
||||
RouterModule.forRoot([], {relativeLinkResolution: 'legacy'}),
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export class ScheduleProvider implements OnDestroy {
|
||||
private _uuidSubscription?: Subscription;
|
||||
|
||||
constructor(private readonly dataProvider: DataProvider) {
|
||||
window.addEventListener('storage', this.storageEventListener.bind(this));
|
||||
window.addEventListener('storage', this.storageListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,9 +87,9 @@ export class ScheduleProvider implements OnDestroy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen to updates in local storage
|
||||
* What to do when local storage updates
|
||||
*/
|
||||
private storageEventListener(event: StorageEvent) {
|
||||
private storageEventHandler(event: StorageEvent) {
|
||||
if (
|
||||
event.newValue &&
|
||||
event.storageArea === localStorage &&
|
||||
@@ -99,6 +99,11 @@ export class ScheduleProvider implements OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen to updates in local storage
|
||||
*/
|
||||
private storageListener = this.storageEventHandler.bind(this);
|
||||
|
||||
/**
|
||||
* Load Date Series
|
||||
*/
|
||||
@@ -192,6 +197,6 @@ export class ScheduleProvider implements OnDestroy {
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this._uuidSubscription?.unsubscribe();
|
||||
window.removeEventListener('storage', this.storageEventListener.bind(this));
|
||||
window.removeEventListener('storage', this.storageListener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ describe('SettingsProvider', () => {
|
||||
CONFIG_SETTINGS_MOCK[3].categories[0],
|
||||
CONFIG_SETTINGS_MOCK[3].name,
|
||||
);
|
||||
await expect(value).toEqual(SETTING_VALUES_MOCK.profile.group);
|
||||
await expect(value).toEqual(SETTING_VALUES_MOCK.profile.group as string);
|
||||
});
|
||||
|
||||
it('should set default setting value if no persisted value exist', async () => {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {NgModule} from '@angular/core';
|
||||
import {IonicStorageModule} from '@ionic/storage';
|
||||
import {IonicStorageModule} from '@ionic/storage-angular';
|
||||
import {StorageProvider} from './storage.provider';
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,10 +48,10 @@ describe('StorageProvider', () => {
|
||||
});
|
||||
|
||||
it('should call ready method of storage on init', () => {
|
||||
spyOn(storage, 'ready');
|
||||
spyOn(storage, 'create');
|
||||
storageProvider.init();
|
||||
|
||||
expect(storage.ready).toHaveBeenCalled();
|
||||
expect(storage.create).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should call set method of storage to put a value', () => {
|
||||
|
||||
@@ -102,8 +102,8 @@ export class StorageProvider {
|
||||
/**
|
||||
* Initializes the storage (waits until it's ready)
|
||||
*/
|
||||
async init(): Promise<any> {
|
||||
return this.storage.ready();
|
||||
async init(): Promise<void> {
|
||||
await this.storage.create();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,8 @@ import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import moment from 'moment';
|
||||
import {Subscription} from 'rxjs';
|
||||
import {logger} from '../_helpers/ts-logger';
|
||||
|
||||
// TODO: use import for opening_hours when the change is published with a new update
|
||||
// see https://github.com/opening-hours/opening_hours.js/pull/407
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, unicorn/prefer-module
|
||||
const ohFunction = require('opening_hours');
|
||||
|
||||
|
||||
@@ -29,4 +29,4 @@ export const environment = {
|
||||
* import the following file, but please comment it out in production mode
|
||||
* because it will have performance impact when throw error
|
||||
*/
|
||||
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
|
||||
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
|
||||
|
||||
@@ -71,7 +71,7 @@ import 'core-js/es7/reflect';
|
||||
/***************************************************************************************************
|
||||
* Zone JS is required by Angular itself.
|
||||
*/
|
||||
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||
import 'zone.js'; // Included with Angular CLI.
|
||||
|
||||
/***************************************************************************************************
|
||||
* APPLICATION IMPORTS
|
||||
|
||||
@@ -13,13 +13,12 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
|
||||
|
||||
import 'zone.js/testing';
|
||||
import {getTestBed} from '@angular/core/testing';
|
||||
import {
|
||||
BrowserDynamicTestingModule,
|
||||
platformBrowserDynamicTesting,
|
||||
} from '@angular/platform-browser-dynamic/testing';
|
||||
import 'zone.js/dist/zone-testing';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
declare const require: any;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/spec",
|
||||
"baseUrl": "./"
|
||||
,
|
||||
},
|
||||
"files": [
|
||||
"test.ts"
|
||||
],
|
||||
"include": [
|
||||
"polyfills.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/app",
|
||||
"baseUrl": "./"
|
||||
},
|
||||
"files": [
|
||||
"main.ts",
|
||||
"polyfills.ts"
|
||||
"src/main.ts",
|
||||
"src/polyfills.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
@@ -2,14 +2,18 @@
|
||||
"extends": "./node_modules/@openstapps/configuration/tsconfig.json",
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"declaration": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"strictPropertyInitialization": false,
|
||||
"resolveJsonModule": true,
|
||||
"downlevelIteration": true,
|
||||
"importHelpers": true,
|
||||
"module": "es2020",
|
||||
"lib": [
|
||||
"es2017",
|
||||
"es2018",
|
||||
"dom"
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
19
tsconfig.spec.json
Normal file
19
tsconfig.spec.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "../out-tsc/spec",
|
||||
"baseUrl": "./",
|
||||
"types": [
|
||||
"jasmine",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"src/test.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/polyfills.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user