From 4b17868fb47abf6ed2e994b6c1d0961b34b912a9 Mon Sep 17 00:00:00 2001 From: GeoSot Date: Sat, 19 Feb 2022 16:08:16 +0200 Subject: [PATCH] tests: revisit all tests using Promise.reject instead of throwing an error (#35765) --- js/tests/unit/alert.spec.js | 4 +-- js/tests/unit/carousel.spec.js | 4 +-- js/tests/unit/collapse.spec.js | 8 ++--- js/tests/unit/dom/event-handler.spec.js | 4 +-- js/tests/unit/dropdown.spec.js | 48 ++++++++++++------------- js/tests/unit/modal.spec.js | 24 ++++++------- js/tests/unit/offcanvas.spec.js | 8 ++--- js/tests/unit/tab.spec.js | 20 +++++------ js/tests/unit/toast.spec.js | 8 ++--- js/tests/unit/tooltip.spec.js | 16 ++++----- 10 files changed, 72 insertions(+), 72 deletions(-) diff --git a/js/tests/unit/alert.spec.js b/js/tests/unit/alert.spec.js index e2fe49246a..bfe6f9a292 100644 --- a/js/tests/unit/alert.spec.js +++ b/js/tests/unit/alert.spec.js @@ -102,7 +102,7 @@ describe('Alert', () => { }) it('should not remove alert if close event is prevented', () => { - return new Promise(resolve => { + return new Promise((resolve, reject) => { fixtureEl.innerHTML = '
' const getAlert = () => document.querySelector('.alert') @@ -118,7 +118,7 @@ describe('Alert', () => { }) alertEl.addEventListener('closed.bs.alert', () => { - throw new Error('should not fire closed event') + reject(new Error('should not fire closed event')) }) alert.close() diff --git a/js/tests/unit/carousel.spec.js b/js/tests/unit/carousel.spec.js index 1c91cebec4..175f9562c6 100644 --- a/js/tests/unit/carousel.spec.js +++ b/js/tests/unit/carousel.spec.js @@ -270,7 +270,7 @@ describe('Carousel', () => { }) it('should stay at the start when the prev method is called and wrap is false', () => { - return new Promise(resolve => { + return new Promise((resolve, reject) => { fixtureEl.innerHTML = [ '