From 9c285b00a5279c66ee815497b6238c1a60168c14 Mon Sep 17 00:00:00 2001 From: Robert Baillie Date: Tue, 14 Dec 2021 16:08:31 +0000 Subject: [PATCH] Added ability to hide the footer on the modal --- .../default/lwc/modal/__tests__/modal.test.js | 21 +++++++++++++++++-- .../ortoo-core/default/lwc/modal/modal.html | 2 +- .../ortoo-core/default/lwc/modal/modal.js | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/framework/default/ortoo-core/default/lwc/modal/__tests__/modal.test.js b/framework/default/ortoo-core/default/lwc/modal/__tests__/modal.test.js index a75f04e61af..888d00c5c98 100644 --- a/framework/default/ortoo-core/default/lwc/modal/__tests__/modal.test.js +++ b/framework/default/ortoo-core/default/lwc/modal/__tests__/modal.test.js @@ -9,8 +9,6 @@ describe('c-modal', () => { } }); - // TODO: test the cancel event - it( 'Component is set to visible, the title, contents and footer slots are shown', () => { const element = createElement('c-modal', { is: Modal @@ -64,6 +62,25 @@ describe('c-modal', () => { expect( footerDiv ).toBe( null ); }); + it( 'Component is set to visible, and hideFooter is true, the title, contents are show, but the footer slot is not', () => { + const element = createElement('c-modal', { + is: Modal + }); + element.visible = true; + element.hideFooter = true; + + document.body.appendChild( element ); + + const titleDiv = element.shadowRoot.querySelector( 'slot[name="title"]' ); + expect( titleDiv ).not.toBe( null ); + + const contentsDiv = element.shadowRoot.querySelector( 'slot[name="contents"]' ); + expect( contentsDiv ).not.toBe( null ); + + const footerDiv = element.shadowRoot.querySelector( 'slot[name="footer"]' ); + expect( footerDiv ).toBe( null ); + }); + it( 'Will issue a cancel event when "escape" is pressed', () => { const element = createElement('c-modal', { diff --git a/framework/default/ortoo-core/default/lwc/modal/modal.html b/framework/default/ortoo-core/default/lwc/modal/modal.html index b55e8f406ab..30dd2d775d9 100644 --- a/framework/default/ortoo-core/default/lwc/modal/modal.html +++ b/framework/default/ortoo-core/default/lwc/modal/modal.html @@ -35,7 +35,7 @@