From 0b0cf4d5c61020bf895949cd6fbb7dce7765ceb2 Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Wed, 4 Sep 2024 16:21:24 -0400 Subject: [PATCH 1/2] Assign found OAM array to foundManuscript instead of push --- app/components/found-manuscripts/index.js | 2 +- .../components/found-manuscripts/component-test.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/components/found-manuscripts/index.js b/app/components/found-manuscripts/index.js index 52915eb7..1c8a9fc7 100644 --- a/app/components/found-manuscripts/index.js +++ b/app/components/found-manuscripts/index.js @@ -46,7 +46,7 @@ export default class FoundManuscriptsComponent extends Component { const foundOAMss = yield this.oaManuscriptService.lookup(doi); if (foundOAMss) { - this.foundManuscripts.push(foundOAMss); + this.foundManuscripts = [...foundOAMss]; } }; } diff --git a/tests/integration/components/found-manuscripts/component-test.js b/tests/integration/components/found-manuscripts/component-test.js index 9b026f80..1ace9caf 100644 --- a/tests/integration/components/found-manuscripts/component-test.js +++ b/tests/integration/components/found-manuscripts/component-test.js @@ -47,10 +47,12 @@ module('Integration | Component | found-manuscripts', (hooks) => { const mockMsService = Service.extend({ lookup(doi) { assert.ok(doi, 'DOI needs to be present'); - return Promise.resolve({ - name: 'This is a moo', - url: 'http://moo.example.com', - }); + return Promise.resolve([ + { + name: 'This is a moo', + url: 'http://moo.example.com', + }, + ]); }, }); From 140aba9c44a26c53ebe06365464698022ab099bc Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Wed, 4 Sep 2024 16:29:09 -0400 Subject: [PATCH 2/2] Return empty array for error conditions --- app/services/oa-manuscript-service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/oa-manuscript-service.js b/app/services/oa-manuscript-service.js index c8228262..1a935162 100644 --- a/app/services/oa-manuscript-service.js +++ b/app/services/oa-manuscript-service.js @@ -23,7 +23,7 @@ export default class OAManuscriptService extends Service { console.assert(!!doi, '%cNo DOI was provided to the manuscript service lookup.', 'color: red;'); if (!this.lookUpPath || !doi) { - return; + return []; } const url = `${this.lookUpPath}?doi=${doi}`; @@ -38,7 +38,7 @@ export default class OAManuscriptService extends Service { .then((resp) => { if (resp.status !== 200) { console.log(`%cFailed to lookup files for DOI (${doi}). Reason: "${resp.message}"`, 'color: red;'); - return {}; + return []; } return resp.json(); })