Skip to content

Commit 3c08054

Browse files
author
Andrea Barbasso
committed
[DSC-2140] add tests
1 parent 2b6ef99 commit 3c08054

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/app/core/shared/metadata.utils.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { isUndefined } from '../../shared/empty.util';
22
import { v4 as uuidv4 } from 'uuid';
33
import { MetadataMap, MetadataValue, MetadataValueFilter, MetadatumViewModel } from './metadata.models';
4-
import { Metadata } from './metadata.utils';
4+
import { Metadata, PLACEHOLDER_VALUE } from './metadata.utils';
55

66
const mdValue = (value: string, language?: string, authority?: string): MetadataValue => {
77
return Object.assign(new MetadataValue(), {
@@ -306,4 +306,21 @@ describe('Metadata', () => {
306306
testAllWithLimit(multiMap, 'dc.title', [dcTitle1], 1);
307307
});
308308
});
309+
310+
describe('Placeholder values', () => {
311+
it('should ignore placeholder values in get methods', () => {
312+
const placeholderMd = mdValue(PLACEHOLDER_VALUE);
313+
const key = 'dc.test.placeholder';
314+
const map = { 'dc.test.placeholder': [placeholderMd] };
315+
316+
expect(Metadata.all(map, key).length).toEqual(0);
317+
expect(Metadata.allValues(map, key).length).toEqual(0);
318+
expect(Metadata.has(map, key)).toBeFalsy();
319+
expect(Metadata.first(map, key)).toBeUndefined();
320+
expect(Metadata.firstValue(map, key)).toBeUndefined();
321+
expect(Metadata.hasValue(placeholderMd)).toBeFalsy();
322+
expect(Metadata.valueMatches(placeholderMd, null)).toBeFalsy();
323+
});
324+
});
325+
309326
});

src/app/core/shared/metadata.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class Metadata {
157157
return false;
158158
}
159159
if (isObject(value) && value.hasOwnProperty('value')) {
160-
return isNotEmpty(value.value);
160+
return isNotEmpty(value.value) && value.value !== PLACEHOLDER_VALUE;
161161
}
162162
return true;
163163
}

0 commit comments

Comments
 (0)