Skip to content

Commit

Permalink
test: fix broken tests caused by missing cache dependency (#1001)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
thorbrink authored Jan 8, 2025
1 parent c480ff9 commit a35ee44
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions source/js/modal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ const defaultModalData: IModalData = {
}

function initializeModalComponent() {
const modalInstance = new Modal()
modalInstance.enableModals()
new Modal()
}

async function renderModalComponent(partialModalData: Partial<IModalData>) {
Expand Down Expand Up @@ -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 = `<p>test</p>`
await renderModalComponent({heading: 'Modal heading'})
const modalElement = document.querySelector('.c-modal') as HTMLDialogElement
Expand Down
2 changes: 1 addition & 1 deletion source/js/select/Select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a35ee44

Please sign in to comment.