From 5dd82dca25fb06cc8bf19fa89cf28ff996b2b0c2 Mon Sep 17 00:00:00 2001 From: Vito Albano Date: Tue, 8 Nov 2016 15:52:10 +0000 Subject: [PATCH] Improved test for component and added translation --- .../ng2-alfresco-userinfo/karma.conf.js | 14 +- .../src/assets/translation.service.mock.ts | 37 ++ .../src/components/user-info.component.html | 53 +- .../components/user-info.component.spec.ts | 515 ++++++++++-------- .../src/components/user-info.component.ts | 8 +- .../ng2-alfresco-userinfo/src/i18n/en.json | 13 + .../ng2-alfresco-userinfo/src/i18n/it.json | 12 + .../src/services/bpm-user.service.spec.ts | 25 +- .../src/services/ecm-user.service.spec.ts | 14 +- .../src/services/ecm-user.service.ts | 7 +- 10 files changed, 426 insertions(+), 272 deletions(-) create mode 100644 ng2-components/ng2-alfresco-userinfo/src/assets/translation.service.mock.ts create mode 100644 ng2-components/ng2-alfresco-userinfo/src/i18n/en.json create mode 100644 ng2-components/ng2-alfresco-userinfo/src/i18n/it.json diff --git a/ng2-components/ng2-alfresco-userinfo/karma.conf.js b/ng2-components/ng2-alfresco-userinfo/karma.conf.js index 2b805693c3..3558dce80d 100644 --- a/ng2-components/ng2-alfresco-userinfo/karma.conf.js +++ b/ng2-components/ng2-alfresco-userinfo/karma.conf.js @@ -24,8 +24,8 @@ module.exports = function (config) { 'node_modules/zone.js/dist/fake-async-test.js', // RxJs - { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, - { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false}, // Paths loaded via module imports: // Angular itself @@ -44,11 +44,13 @@ module.exports = function (config) { {pattern: 'dist/**/*.css', included: true, served: true, watched: true}, // ng2-components - { pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false }, + {pattern: 'node_modules/ng2-alfresco-core/dist/**/*.js', included: false, served: true, watched: false}, // Fake files - { pattern: 'src/assets/ecmImg.gif', included: false, watched: true, served: true }, - { pattern: 'src/assets/bpmImg.gif', included: false, watched: true, served: true }, - { pattern: 'src/img/anonymous.gif', included: false, watched: true, served: true }, + {pattern: 'src/assets/ecmImg.gif', included: false, watched: true, served: true}, + {pattern: 'src/assets/bpmImg.gif', included: false, watched: true, served: true}, + {pattern: 'src/img/anonymous.gif', included: false, watched: true, served: true}, + {pattern: 'src/img/blueBanner.png', included: false, watched: true, served: true}, + {pattern: 'src/img/orangeBanner.png', included: false, watched: true, served: true}, // paths to support debugging with source maps in dev tools {pattern: 'src/**/*.ts', included: false, watched: false}, diff --git a/ng2-components/ng2-alfresco-userinfo/src/assets/translation.service.mock.ts b/ng2-components/ng2-alfresco-userinfo/src/assets/translation.service.mock.ts new file mode 100644 index 0000000000..3ddf9a9050 --- /dev/null +++ b/ng2-components/ng2-alfresco-userinfo/src/assets/translation.service.mock.ts @@ -0,0 +1,37 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Observable } from 'rxjs/Rx'; +import { EventEmitter } from '@angular/core'; + +export interface LangChangeEvent { + lang: string; + translations: any; +} + +export class TranslationMock { + + public onLangChange: EventEmitter = new EventEmitter(); + + addTranslationFolder() { + + } + + public get(key: string|Array, interpolateParams?: Object): Observable { + return Observable.of(key); + } +} diff --git a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html index 2e17fc6186..b58e6b22c9 100644 --- a/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html +++ b/ng2-components/ng2-alfresco-userinfo/src/components/user-info.component.html @@ -1,66 +1,73 @@
-
+
user-info-profile-button
-