From 1449a9300aba0a163515e6ec091ee8bf73d8fc22 Mon Sep 17 00:00:00 2001 From: umbobabo Date: Tue, 14 Mar 2023 08:22:20 +0000 Subject: [PATCH] fix: remove usage of backgroundBox as string --- src/lib/get-topper-settings.js | 12 +++-------- test/lib/get-topper-settings.test.js | 30 ++++------------------------ 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/lib/get-topper-settings.js b/src/lib/get-topper-settings.js index 1bf5909..130c79f 100644 --- a/src/lib/get-topper-settings.js +++ b/src/lib/get-topper-settings.js @@ -106,16 +106,10 @@ const useEditoriallySelectedTopper = (content) => { if (content.topper.layout === 'full-bleed-offset') { backgroundColour = 'wheat'; } else if (content.topper.layout === 'deep-landscape') { - // If the backgroundBox is present, use its color to determine a background colour - // The background color won't be visible due to the overlapping image, however, it's needed to - // determine the text color - if (content.topper.backgroundBox) { - backgroundColour = - content.topper.backgroundBox === 'light' ? 'white' : 'black'; - } else if (!hasDarkBackground(content.topper.backgroundColour)) { - backgroundColour = 'white'; - } else { + if (hasDarkBackground(content.topper.backgroundColour)) { backgroundColour = 'black'; + } else { + backgroundColour = 'white'; } } else if ( content.topper.backgroundColour === 'pink' || diff --git a/test/lib/get-topper-settings.test.js b/test/lib/get-topper-settings.test.js index 20b3866..e53bf2b 100644 --- a/test/lib/get-topper-settings.test.js +++ b/test/lib/get-topper-settings.test.js @@ -114,21 +114,22 @@ describe('Get topper settings', () => { expect(topper.backgroundColour).to.equal('wheat'); }); - it('sets the `backgroundColour` to `white` if layout is deep landscape and background is light', () => { + it('sets the `backgroundColour` to `white` if layout is deep landscape and the background is auto', () => { const topper = getTopperSettings({ - topper: { layout: 'deep-landscape', backgroundColour: 'paper' } + topper: { layout: 'deep-landscape', backgroundColour: 'auto' } }); expect(topper.backgroundColour).to.equal('white'); }); - it('sets the `backgroundColour` to `black` if layout is deep landscape and background is dark', () => { + it('sets the `backgroundColour` to `black` if layout is deep landscape and background is slate', () => { const topper = getTopperSettings({ topper: { layout: 'deep-landscape', backgroundColour: 'slate' } }); expect(topper.backgroundColour).to.equal('black'); }); + it('sets the `backgroundColour` to `white` if layout is deep landscape and background is undefined', () => { const topper = getTopperSettings({ topper: { layout: 'deep-landscape' } @@ -136,29 +137,6 @@ describe('Get topper settings', () => { expect(topper.backgroundColour).to.equal('white'); }); - - describe('When a background Box is present', () => { - it('sets the `backgroundColour` to `white` if layout is deep landscape and background Box is light', () => { - const topper = getTopperSettings({ - topper: { - layout: 'deep-landscape', - backgroundBox: 'light' - } - }); - - expect(topper.backgroundColour).to.equal('white'); - }); - it('sets the `backgroundColour` to `black` if layout is deep landscape and background Box is dark', () => { - const topper = getTopperSettings({ - topper: { - layout: 'deep-landscape', - backgroundBox: 'dark' - } - }); - - expect(topper.backgroundColour).to.equal('black'); - }); - }); }); describe('Podcast', () => {