diff options
| author | Johann-S <[email protected]> | 2020-05-06 07:23:05 +0200 |
|---|---|---|
| committer | Johann-S <[email protected]> | 2020-05-06 07:55:48 +0200 |
| commit | 650a7a7b76c8fa82d869194a9db5c01ebe29e33c (patch) | |
| tree | 3e861e655765a486ef24b9b9369622d3246b0c31 /js/tests/unit | |
| parent | d1575b6b6bbdcf7cd2371953b4d3d165ae941c02 (diff) | |
| download | bootstrap-650a7a7b76c8fa82d869194a9db5c01ebe29e33c.tar.xz bootstrap-650a7a7b76c8fa82d869194a9db5c01ebe29e33c.zip | |
add unit tests to ensure our plugins works in jquery
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/jquery.spec.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/js/tests/unit/jquery.spec.js b/js/tests/unit/jquery.spec.js new file mode 100644 index 000000000..ba41d49ef --- /dev/null +++ b/js/tests/unit/jquery.spec.js @@ -0,0 +1,57 @@ +/* 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 Popover from '../../src/popover' +import ScrollSpy from '../../src/scrollspy' +import Tab from '../../src/tab' +import Toast from '../../src/toast' +import Tooltip from '../../src/tooltip' + +/** Test helpers */ +import { getFixture, clearFixture } 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(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', done => { + fixtureEl.innerHTML = [ + '<div class="alert">', + ' <button type="button" data-dismiss="alert">x</button>', + '</div>' + ].join('') + + $(fixtureEl).find('.alert') + .one('closed.bs.alert', () => { + expect($(fixtureEl).find('.alert').length).toEqual(0) + done() + }) + + $(fixtureEl).find('button').click() + }) +}) |
