mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
small fixes
This commit is contained in:
@@ -95,6 +95,38 @@ describe('BrowserKlaroService', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('initialize with user', () => {
|
||||
beforeEach(() => {
|
||||
spyOn((service as any), 'getUser$').and.returnValue(observableOf(user));
|
||||
translateService.get.and.returnValue(observableOf('loading...'));
|
||||
spyOn(service, 'addAppMessages');
|
||||
spyOn((service as any), 'initializeUser');
|
||||
spyOn(service, 'translateConfiguration');
|
||||
});
|
||||
it('to call the initialize user method and other methods', () => {
|
||||
service.initialize();
|
||||
expect((service as any).initializeUser).toHaveBeenCalledWith(user);
|
||||
expect(service.addAppMessages).toHaveBeenCalled();
|
||||
expect(service.translateConfiguration).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('to not call the initialize user method, but the other methods', () => {
|
||||
beforeEach(() => {
|
||||
spyOn((service as any), 'getUser$').and.returnValue(observableOf(undefined));
|
||||
translateService.get.and.returnValue(observableOf('loading...'));
|
||||
spyOn(service, 'addAppMessages');
|
||||
spyOn((service as any), 'initializeUser');
|
||||
spyOn(service, 'translateConfiguration');
|
||||
});
|
||||
it('to call all ', () => {
|
||||
service.initialize();
|
||||
expect((service as any).initializeUser).not.toHaveBeenCalledWith(user);
|
||||
expect(service.addAppMessages).toHaveBeenCalled();
|
||||
expect(service.translateConfiguration).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('addAppMessages', () => {
|
||||
service.addAppMessages();
|
||||
expect(mockConfig.translations.en[appName]).toBeDefined();
|
||||
@@ -203,4 +235,3 @@ describe('BrowserKlaroService', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -11,12 +11,12 @@ import { hasValue, isNotEmpty } from '../empty.util';
|
||||
import { CookieService } from '../../core/services/cookie.service';
|
||||
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { klaroConfiguration } from './klaro-configuration';
|
||||
import { ANONYMOUS_STORAGE_NAME_KLARO, klaroConfiguration } from './klaro-configuration';
|
||||
import { Operation } from 'fast-json-patch';
|
||||
|
||||
export const HAS_AGREED_END_USER = 'dsHasAgreedEndUser';
|
||||
export const COOKIE_MDFIELD = 'dspace.agreements.cookies';
|
||||
export const ANONYMOUS_STORAGE_NAME_KLARO = 'klaro-anonymous';
|
||||
|
||||
const cookieNameMessagePrefix = 'cookies.consent.app.title.';
|
||||
const cookieDescriptionMessagePrefix = 'cookies.consent.app.description.';
|
||||
const cookiePurposeMessagePrefix = 'cookies.consent.purpose.';
|
||||
@@ -34,6 +34,7 @@ export class BrowserKlaroService extends KlaroService {
|
||||
}
|
||||
|
||||
initialize() {
|
||||
console.log(this.klaroConfig)
|
||||
this.translateService.setDefaultLang(environment.defaultLanguage);
|
||||
|
||||
const user$: Observable<EPerson> = this.getUser$();
|
||||
@@ -43,6 +44,7 @@ export class BrowserKlaroService extends KlaroService {
|
||||
observableCombineLatest(user$, translationServiceReady$)
|
||||
.subscribe(([user, translation]: [EPerson, string]) => {
|
||||
user = cloneDeep(user);
|
||||
|
||||
if (hasValue(user)) {
|
||||
this.initializeUser(user);
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
import { TOKENITEM } from '../../core/auth/models/auth-token-info.model';
|
||||
import { IMPERSONATING_COOKIE, REDIRECT_COOKIE } from '../../core/auth/auth.service';
|
||||
import { LANG_COOKIE } from '../../core/locale/locale.service';
|
||||
import { ANONYMOUS_STORAGE_NAME_KLARO, HAS_AGREED_END_USER } from './browser-klaro.service';
|
||||
import { HAS_AGREED_END_USER } from './browser-klaro.service';
|
||||
|
||||
export const ANONYMOUS_STORAGE_NAME_KLARO = 'klaro-anonymous';
|
||||
|
||||
export const klaroConfiguration: any = {
|
||||
storageName: ANONYMOUS_STORAGE_NAME_KLARO,
|
||||
|
Reference in New Issue
Block a user