From a35ee4401ede5049d676dbf17a4c2a20e3f414a0 Mon Sep 17 00:00:00 2001 From: Thor Brink Date: Wed, 8 Jan 2025 08:39:00 +0100 Subject: [PATCH] test: fix broken tests caused by missing cache dependency (#1001) * fix: add StaticCache to component instantiation in CLI * fix: remove 'only' from test cases for modal and select components * test: fix modal test broken due to repeated modal enabling --- cli.php | 2 +- source/js/modal.test.ts | 5 ++--- source/js/select/Select.test.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cli.php b/cli.php index cdab1495e..6eaa4229c 100755 --- a/cli.php +++ b/cli.php @@ -25,7 +25,7 @@ private function renderComponent(string $componentClass, string $view, string $c throw new Error("Could not decode JSON data"); } - $component = new $componentClass($data); + $component = new $componentClass($data, new ComponentLibrary\Cache\StaticCache()); $componentClassPath = (new ReflectionClass($componentClass))->getFileName(); $componentClassDir = dirname($componentClassPath); diff --git a/source/js/modal.test.ts b/source/js/modal.test.ts index c26caba44..fb5ecb195 100644 --- a/source/js/modal.test.ts +++ b/source/js/modal.test.ts @@ -37,8 +37,7 @@ const defaultModalData: IModalData = { } function initializeModalComponent() { - const modalInstance = new Modal() - modalInstance.enableModals() + new Modal() } async function renderModalComponent(partialModalData: Partial) { @@ -143,7 +142,7 @@ describe('modal', () => { expect(Gallery).toHaveBeenCalledTimes(1) }) - it.only('close modal on backdrop click', async () => { + it('close modal on backdrop click', async () => { document.body.innerHTML = `

test

` await renderModalComponent({heading: 'Modal heading'}) const modalElement = document.querySelector('.c-modal') as HTMLDialogElement diff --git a/source/js/select/Select.test.ts b/source/js/select/Select.test.ts index a55d098b0..3b6dd7d8f 100644 --- a/source/js/select/Select.test.ts +++ b/source/js/select/Select.test.ts @@ -51,7 +51,7 @@ describe('Select', () => { document.body.innerHTML = ''; }) - it.only('should update value on select when clicking option list item', async () => { + it('should update value on select when clicking option list item', async () => { const options = { 'test-1': 'Test 1', 'test-2': 'Test 2' }; await renderSelectComponent({ options }); const select = document.querySelector('select') as HTMLSelectElement