From 3ea39841c8049525e31e9f4d6300f0c60cdb42de Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 24 Jan 2023 13:33:51 +0100 Subject: Adding upstream version 5.2.3+dfsg. Signed-off-by: Daniel Baumann --- js/tests/unit/jquery.spec.js | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 js/tests/unit/jquery.spec.js (limited to 'js/tests/unit/jquery.spec.js') diff --git a/js/tests/unit/jquery.spec.js b/js/tests/unit/jquery.spec.js new file mode 100644 index 0000000..7da39d6 --- /dev/null +++ b/js/tests/unit/jquery.spec.js @@ -0,0 +1,60 @@ +/* eslint-env jquery */ + +import Alert from '../../src/alert' +import Button from '../../src/button' +import Carousel from '../../src/carousel' +import Collapse from '../../src/collapse' +import Dropdown from '../../src/dropdown' +import Modal from '../../src/modal' +import Offcanvas from '../../src/offcanvas' +import Popover from '../../src/popover' +import ScrollSpy from '../../src/scrollspy' +import Tab from '../../src/tab' +import Toast from '../../src/toast' +import Tooltip from '../../src/tooltip' +import { clearFixture, getFixture } from '../helpers/fixture' + +describe('jQuery', () => { + let fixtureEl + + beforeAll(() => { + fixtureEl = getFixture() + }) + + afterEach(() => { + clearFixture() + }) + + it('should add all plugins in jQuery', () => { + expect(Alert.jQueryInterface).toEqual(jQuery.fn.alert) + expect(Button.jQueryInterface).toEqual(jQuery.fn.button) + expect(Carousel.jQueryInterface).toEqual(jQuery.fn.carousel) + expect(Collapse.jQueryInterface).toEqual(jQuery.fn.collapse) + expect(Dropdown.jQueryInterface).toEqual(jQuery.fn.dropdown) + expect(Modal.jQueryInterface).toEqual(jQuery.fn.modal) + expect(Offcanvas.jQueryInterface).toEqual(jQuery.fn.offcanvas) + expect(Popover.jQueryInterface).toEqual(jQuery.fn.popover) + expect(ScrollSpy.jQueryInterface).toEqual(jQuery.fn.scrollspy) + expect(Tab.jQueryInterface).toEqual(jQuery.fn.tab) + expect(Toast.jQueryInterface).toEqual(jQuery.fn.toast) + expect(Tooltip.jQueryInterface).toEqual(jQuery.fn.tooltip) + }) + + it('should use jQuery event system', () => { + return new Promise(resolve => { + fixtureEl.innerHTML = [ + '
', + ' ', + '
' + ].join('') + + $(fixtureEl).find('.alert') + .one('closed.bs.alert', () => { + expect($(fixtureEl).find('.alert')).toHaveSize(0) + resolve() + }) + + $(fixtureEl).find('button').trigger('click') + }) + }) +}) -- cgit v1.2.3