Skip to content

Commit 161612f

Browse files
committed
Update valueFor stringfield falsey check
1 parent a891880 commit 161612f

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/models/metadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export class Metadata {
594594
if (value) return value;
595595

596596
const rawValue = this.rawMetadata[key];
597-
if (rawValue) {
597+
if (rawValue != null) {
598598
return new StringField(rawValue);
599599
}
600600

test/models/metadata.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ describe('Metadata', () => {
174174
expect(snakeValue).to.be.undefined;
175175
expect(dashValue).to.be.undefined;
176176
});
177+
178+
it('valueFor returns StringField for falsey value', async () => {
179+
const json = { identifier: 'foo', beepboop: 0 };
180+
const metadata = new Metadata(json);
181+
const value = metadata.valueFor('beepboop');
182+
expect(value).to.exist;
183+
expect(value?.value).to.equal('0');
184+
});
177185
});
178186

179187
describe('allMetadataKeys', () => {

0 commit comments

Comments
 (0)