From 59bf4ffb51c9593cb9c1d2765c86bfbc360d33c5 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Sun, 4 Dec 2022 16:59:34 -0600 Subject: [PATCH] test uncovered lines --- packages/core/tests/pattern-draft.test.mjs | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/core/tests/pattern-draft.test.mjs b/packages/core/tests/pattern-draft.test.mjs index a5b80a394f9..d66459d6780 100644 --- a/packages/core/tests/pattern-draft.test.mjs +++ b/packages/core/tests/pattern-draft.test.mjs @@ -33,7 +33,6 @@ describe('Pattern', () => { expect(count).to.equal(2) }) }) - it('Should check whether a part is needed', () => { const partA = { name: 'test.partA', @@ -131,7 +130,38 @@ describe('Pattern', () => { expect(pattern.__wants('test.partB')).to.equal(true) expect(pattern.__wants('test.partC')).to.equal(false) }) + it('should log an error if it fails to inject a part into another', () => { + const otherPart = { + name: 'otherPart', + draft: function ({ part, points }) { + points.oops = { + clone: () => { + throw new Error('something bad happened') + }, + } + return part + }, + } + const front = { + name: 'front', + from: otherPart, + draft: function (part) { + return part + }, + } + const Test = new Design({ + name: 'test', + parts: [front, otherPart], + }) + const pattern = new Test() + pattern.draft() + + console.log(pattern.setStores[pattern.activeSet].logs.error[0]) + expect(pattern.setStores[pattern.activeSet].logs.error[0]).to.include( + 'Could not inject part `otherPart` into part `front`' + ) + }) /* it('Should return all render props', () => {