From afa411419b4b95e4ba63d5328464805c00dab018 Mon Sep 17 00:00:00 2001 From: mekkyz Date: Mon, 11 Sep 2023 09:20:12 +0000 Subject: [PATCH] fix: converting test id to number --- .../ResearchPlanDetailsAttachments.spec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/javascripts/packs/src/apps/mydb/elements/details/researchPlans/attachmentsTab/ResearchPlanDetailsAttachments.spec.js b/spec/javascripts/packs/src/apps/mydb/elements/details/researchPlans/attachmentsTab/ResearchPlanDetailsAttachments.spec.js index 79c94c6537..b285c54e02 100644 --- a/spec/javascripts/packs/src/apps/mydb/elements/details/researchPlans/attachmentsTab/ResearchPlanDetailsAttachments.spec.js +++ b/spec/javascripts/packs/src/apps/mydb/elements/details/researchPlans/attachmentsTab/ResearchPlanDetailsAttachments.spec.js @@ -1,3 +1,5 @@ +/* global describe, it, beforeEach, afterEach */ + import React from 'react'; import expect from 'expect'; import Enzyme, { shallow } from 'enzyme'; @@ -10,17 +12,31 @@ import ResearchPlanFactory from 'factories/ResearchPlanFactory'; import ElementStore from 'src/stores/alt/stores/ElementStore'; import EditorFetcher from 'src/fetchers/EditorFetcher'; -import ResearchPlanDetailsAttachments from 'src/apps/mydb/elements/details/researchPlans/attachmentsTab/ResearchPlanDetailsAttachments'; +import ResearchPlanDetailsAttachments from + 'src/apps/mydb/elements/details/researchPlans/attachmentsTab/ResearchPlanDetailsAttachments'; Enzyme.configure({ adapter: new Adapter() }); describe('ResearchPlanDetailsAttachments', async () => { + let stub; + beforeEach(() => { stub = sinon.stub(console, 'error'); }); + afterEach(() => { stub.restore(); }); + describe('.createAttachmentPreviews()', async () => { describe('.when preview was changed', async () => { it('new preview is rendered', async () => { const researchPlanWithAttachment = await ResearchPlanFactory.build( 'with attachment_not_in_body' ); + + // Convert id to number + if (researchPlanWithAttachment.attachments) { + researchPlanWithAttachment.attachments.forEach((attachment) => { + attachment.id = Number(attachment.id); + attachment.identifier = String(attachment.identifier); + }); + } + sinon .stub(EditorFetcher, 'initial') .callsFake(() => new Promise(() => {}));