🧪 Improve test readability by reformatting code for better clarity and consistency in BaseModal unit tests

This commit is contained in:
2026-01-28 22:24:43 +00:00
parent 6d3d81c3c0
commit 5453f80317

View File

@@ -121,7 +121,9 @@ describe('BaseModal', () => {
await nextTick();
const container = document.querySelector('.modal-container');
expect(container.classList.contains(`modal-container--${size}`)).toBe(true);
expect(container.classList.contains(`modal-container--${size}`)).toBe(
true
);
wrapper.unmount();
}
});
@@ -288,7 +290,8 @@ describe('BaseModal', () => {
modelValue: true
},
slots: {
default: '<button id="first-btn">First</button><button>Second</button>'
default:
'<button id="first-btn">First</button><button>Second</button>'
}
});
@@ -305,7 +308,8 @@ describe('BaseModal', () => {
modelValue: true
},
slots: {
default: '<button id="btn1">Button 1</button><button id="btn2">Button 2</button>'
default:
'<button id="btn1">Button 1</button><button id="btn2">Button 2</button>'
}
});
@@ -320,7 +324,10 @@ describe('BaseModal', () => {
expect(document.activeElement).toBe(btn2);
// Press Tab - should cycle to first button
const tabEvent = new KeyboardEvent('keydown', { key: 'Tab', bubbles: true });
const tabEvent = new KeyboardEvent('keydown', {
key: 'Tab',
bubbles: true
});
document.dispatchEvent(tabEvent);
await nextTick();
@@ -442,7 +449,10 @@ describe('BaseModal', () => {
await nextTick();
wrapper.unmount();
expect(removeEventListenerSpy).toHaveBeenCalledWith('keydown', expect.any(Function));
expect(removeEventListenerSpy).toHaveBeenCalledWith(
'keydown',
expect.any(Function)
);
});
it('restores body overflow on unmount', async () => {