mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#9 Unit tests
This commit is contained in:
@@ -56,6 +56,6 @@ export declare class DocumentList implements OnInit, AfterViewChecked, AfterCont
|
||||
* @param key
|
||||
* @returns {string}
|
||||
*/
|
||||
getObjectValue(target: any, key: string): string;
|
||||
getObjectValue(target: any, key: string): any;
|
||||
setupDefaultColumns(): void;
|
||||
}
|
||||
|
@@ -204,7 +204,7 @@ export class DocumentList implements OnInit, AfterViewChecked, AfterContentInit
|
||||
* @param key
|
||||
* @returns {string}
|
||||
*/
|
||||
getObjectValue(target: any, key: string): string {
|
||||
getObjectValue(target: any, key: string): any {
|
||||
let keys = key.split('.');
|
||||
key = '';
|
||||
|
||||
|
@@ -316,4 +316,31 @@ describe('DocumentList', () => {
|
||||
expect(documentList.getNodePath(node)).toBe('swsdp/documentLibrary/fileName');
|
||||
});
|
||||
|
||||
it('should return root object value', () => {
|
||||
var target = {
|
||||
key1: 'value1'
|
||||
};
|
||||
|
||||
expect(documentList.getObjectValue(target, 'key1')).toBe('value1');
|
||||
});
|
||||
|
||||
it('should return no object value when key is missing', () => {
|
||||
var target = {
|
||||
key1: 'value1'
|
||||
};
|
||||
expect(documentList.getObjectValue(target, 'missing')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return nested object value', () => {
|
||||
var target = {
|
||||
key1: {
|
||||
key2: {
|
||||
key3: 'value1'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(documentList.getObjectValue(target, 'key1.key2.key3')).toBe('value1');
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user