From c735ad63ec2edbd9d38de3690a5ddd86f67e92ee Mon Sep 17 00:00:00 2001 From: Brock Allen Date: Mon, 15 Feb 2021 17:06:42 -0500 Subject: [PATCH] fix metadataSeed improperly merged and returned #1305 --- src/MetadataService.js | 8 +++----- test/unit/MetadataService.spec.js | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/MetadataService.js b/src/MetadataService.js index d6d2b97b..630662a3 100644 --- a/src/MetadataService.js +++ b/src/MetadataService.js @@ -59,11 +59,9 @@ export class MetadataService { .then(metadata => { Log.debug("MetadataService.getMetadata: json received"); - var mergedMetadata = this._settings.metadataSeed || {}; - Object.assign(mergedMetadata, metadata); - - this._settings.metadata = mergedMetadata; - return metadata; + var seed = this._settings.metadataSeed || {}; + this._settings.metadata = Object.assign({}, seed, metadata); + return this._settings.metadata; }); } diff --git a/test/unit/MetadataService.spec.js b/test/unit/MetadataService.spec.js index ac597094..882a19ff 100644 --- a/test/unit/MetadataService.spec.js +++ b/test/unit/MetadataService.spec.js @@ -115,7 +115,7 @@ describe("MetadataService", function() { }); }); - it("should merge metadata from seed", function(done) { + it.only("should merge metadata from seed", function(done) { settings.metadataUrl = "http://sts/metadata"; settings.metadataSeed = {test1:"one"}; stubJsonService.result = Promise.resolve({test2:"two"}); @@ -123,6 +123,7 @@ describe("MetadataService", function() { let p = subject.getMetadata(); p.then(result => { + result.should.deep.equal({test1:"one", test2:"two"}); settings.metadata.should.deep.equal({test1:"one", test2:"two"}); done(); });