[ADF-2265] fix user preference null value (#2948)

* fix user preference null value

* fix method call test public
This commit is contained in:
Eugenio Romano 2018-02-15 09:30:35 +00:00 committed by Denys Vuika
parent 63a146616b
commit 6e57cd3e17
4 changed files with 11 additions and 5 deletions

View File

@ -191,8 +191,8 @@ export class AuthenticationService {
* The method save the AUTH ticket in the Storage
*/
saveTicketAuth(): void {
if (this.alfrescoApi.getInstance() && (<any>this.alfrescoApi.getInstance()).getTicketAuth()) {
this.storage.setItem('ticket-AUTH', (<any>this.alfrescoApi.getInstance()).getTicketAuth());
if (this.alfrescoApi.getInstance() && (<any> this.alfrescoApi.getInstance()).getTicketAuth()) {
this.storage.setItem('ticket-AUTH', (<any> this.alfrescoApi.getInstance()).getTicketAuth());
}
}

View File

@ -57,7 +57,7 @@ describe('UserPreferencesService', () => {
appConfig.config = {
pagination: {
'size': 10,
'supportedPageSizes': [ 5, 10, 15, 20 ]
'supportedPageSizes': [5, 10, 15, 20]
}
};
preferences = TestBed.get(UserPreferencesService);
@ -99,6 +99,12 @@ describe('UserPreferencesService', () => {
expect(storage.getItem(propertyKey)).toBe('valueA');
});
it('should null value return default prefix', () => {
storage.setItem('paginationSize', null);
const paginationSize = preferences.getPropertyKey('paginationSize');
expect(preferences.get(paginationSize, 'default')).toBe('default');
});
it('should save value with custom prefix', () => {
preferences.setStoragePrefix('USER_A');
preferences.set('propertyA', 'valueA');

View File

@ -51,7 +51,7 @@ export class UserPreferencesService {
get(property: string, defaultValue?: string): string {
const key = this.getPropertyKey(property);
const value = this.storage.getItem(key);
if (value === undefined) {
if (value === undefined || value === null) {
return defaultValue;
}
return value;

View File

@ -87,7 +87,7 @@ export class TaskFilterService {
/**
* Retrieve all the Tasks filters
*/
getTaskListFilters(appId?: number): Observable<any> {
getTaskListFilters(appId?: number): Observable<FilterRepresentationModel[]> {
return Observable.fromPromise(this.callApiTaskFilters(appId))
.map((response: any) => {
let filters: FilterRepresentationModel[] = [];