mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
[TLC-254] Tests for isObjectEmpty()
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
isNotEmptyOperator,
|
||||
isNotNull,
|
||||
isNotUndefined,
|
||||
isNull,
|
||||
isNull, isObjectEmpty,
|
||||
isUndefined
|
||||
} from './empty.util';
|
||||
|
||||
@@ -444,6 +444,43 @@ describe('Empty Utils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isObjectEmpty', () => {
|
||||
/*
|
||||
isObjectEmpty(); // true
|
||||
isObjectEmpty(null); // true
|
||||
isObjectEmpty(undefined); // true
|
||||
isObjectEmpty(''); // true
|
||||
isObjectEmpty([]); // true
|
||||
isObjectEmpty({}); // true
|
||||
isObjectEmpty({name: null}); // true
|
||||
isObjectEmpty({ name: 'Adam Hawkins', surname : null}); // false
|
||||
*/
|
||||
it('should be empty if no parameter passed', () => {
|
||||
expect(isObjectEmpty()).toBeTrue();
|
||||
})
|
||||
it('should be empty if null parameter passed', () => {
|
||||
expect(isObjectEmpty(null)).toBeTrue();
|
||||
})
|
||||
it('should be empty if undefined parameter passed', () => {
|
||||
expect(isObjectEmpty(undefined)).toBeTrue();
|
||||
})
|
||||
it('should be empty if empty string passed', () => {
|
||||
expect(isObjectEmpty('')).toBeTrue();
|
||||
})
|
||||
it('should be empty if empty array passed', () => {
|
||||
expect(isObjectEmpty([])).toBeTrue();
|
||||
})
|
||||
it('should be empty if empty object passed', () => {
|
||||
expect(isObjectEmpty({})).toBeTrue();
|
||||
})
|
||||
it('should be empty if single key with null value passed', () => {
|
||||
expect(isObjectEmpty({ name: null })).toBeTrue();
|
||||
})
|
||||
it('should NOT be empty if object with at least one non-null value passed', () => {
|
||||
expect(isObjectEmpty({ name: 'Adam Hawkins', surname : null })).toBeFalse();
|
||||
})
|
||||
});
|
||||
|
||||
describe('ensureArrayHasValue', () => {
|
||||
it('should let all arrays pass unchanged, and turn everything else in to empty arrays', () => {
|
||||
const sourceData = {
|
||||
|
Reference in New Issue
Block a user