mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-05 16:42:29 +03:00
Js - use a default JQueryInterface in js components
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import Alert from '../../src/alert'
|
||||
import { getTransitionDurationFromElement } from '../../src/util/index'
|
||||
import { clearFixture, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Alert', () => {
|
||||
let fixtureEl
|
||||
@@ -150,7 +151,7 @@ describe('Alert', () => {
|
||||
|
||||
spyOn(alert, 'close')
|
||||
|
||||
jQueryMock.fn.alert = Alert.jQueryInterface
|
||||
jQueryMock.fn.alert = getJqueryInterfaceForPlugin(Alert)
|
||||
jQueryMock.elements = [alertEl]
|
||||
|
||||
jQueryMock.fn.alert.call(jQueryMock, 'close')
|
||||
@@ -163,7 +164,7 @@ describe('Alert', () => {
|
||||
|
||||
const alertEl = fixtureEl.querySelector('.alert')
|
||||
|
||||
jQueryMock.fn.alert = Alert.jQueryInterface
|
||||
jQueryMock.fn.alert = getJqueryInterfaceForPlugin(Alert)
|
||||
jQueryMock.elements = [alertEl]
|
||||
|
||||
expect(Alert.getInstance(alertEl)).toBeNull()
|
||||
@@ -177,7 +178,7 @@ describe('Alert', () => {
|
||||
|
||||
const alertEl = fixtureEl.querySelector('.alert')
|
||||
|
||||
jQueryMock.fn.alert = Alert.jQueryInterface
|
||||
jQueryMock.fn.alert = getJqueryInterfaceForPlugin(Alert)
|
||||
jQueryMock.elements = [alertEl]
|
||||
|
||||
jQueryMock.fn.alert.call(jQueryMock)
|
||||
@@ -192,7 +193,7 @@ describe('Alert', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.alert = Alert.jQueryInterface
|
||||
jQueryMock.fn.alert = getJqueryInterfaceForPlugin(Alert)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -206,7 +207,7 @@ describe('Alert', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = '_getConfig'
|
||||
|
||||
jQueryMock.fn.alert = Alert.jQueryInterface
|
||||
jQueryMock.fn.alert = getJqueryInterfaceForPlugin(Alert)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Button from '../../src/button'
|
||||
import { getFixture, clearFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Button', () => {
|
||||
let fixtureEl
|
||||
@@ -102,7 +103,7 @@ describe('Button', () => {
|
||||
|
||||
spyOn(button, 'toggle')
|
||||
|
||||
jQueryMock.fn.button = Button.jQueryInterface
|
||||
jQueryMock.fn.button = getJqueryInterfaceForPlugin(Button)
|
||||
jQueryMock.elements = [btnEl]
|
||||
|
||||
jQueryMock.fn.button.call(jQueryMock, 'toggle')
|
||||
@@ -115,7 +116,7 @@ describe('Button', () => {
|
||||
|
||||
const btnEl = fixtureEl.querySelector('.btn')
|
||||
|
||||
jQueryMock.fn.button = Button.jQueryInterface
|
||||
jQueryMock.fn.button = getJqueryInterfaceForPlugin(Button)
|
||||
jQueryMock.elements = [btnEl]
|
||||
|
||||
jQueryMock.fn.button.call(jQueryMock, 'toggle')
|
||||
@@ -129,7 +130,7 @@ describe('Button', () => {
|
||||
|
||||
const btnEl = fixtureEl.querySelector('.btn')
|
||||
|
||||
jQueryMock.fn.button = Button.jQueryInterface
|
||||
jQueryMock.fn.button = getJqueryInterfaceForPlugin(Button)
|
||||
jQueryMock.elements = [btnEl]
|
||||
|
||||
jQueryMock.fn.button.call(jQueryMock)
|
||||
|
||||
@@ -3,6 +3,7 @@ import EventHandler from '../../src/dom/event-handler'
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { isRTL, noop } from '../../src/util/index'
|
||||
import Swipe from '../../src/util/swipe'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Carousel', () => {
|
||||
const { Simulator, PointerEvent } = window
|
||||
@@ -1385,7 +1386,7 @@ describe('Carousel', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.fn.carousel = getJqueryInterfaceForPlugin(Carousel)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.carousel.call(jQueryMock)
|
||||
@@ -1399,7 +1400,7 @@ describe('Carousel', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const carousel = new Carousel(div)
|
||||
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.fn.carousel = getJqueryInterfaceForPlugin(Carousel)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.carousel.call(jQueryMock)
|
||||
@@ -1416,7 +1417,7 @@ describe('Carousel', () => {
|
||||
|
||||
spyOn(carousel, 'to')
|
||||
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.fn.carousel = getJqueryInterfaceForPlugin(Carousel)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.carousel.call(jQueryMock, slideTo)
|
||||
@@ -1430,7 +1431,7 @@ describe('Carousel', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.carousel = Carousel.jQueryInterface
|
||||
jQueryMock.fn.carousel = getJqueryInterfaceForPlugin(Carousel)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Collapse from '../../src/collapse'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { clearFixture, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Collapse', () => {
|
||||
let fixtureEl
|
||||
@@ -949,7 +950,7 @@ describe('Collapse', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.collapse = Collapse.jQueryInterface
|
||||
jQueryMock.fn.collapse = getJqueryInterfaceForPlugin(Collapse)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.collapse.call(jQueryMock)
|
||||
@@ -963,7 +964,7 @@ describe('Collapse', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const collapse = new Collapse(div)
|
||||
|
||||
jQueryMock.fn.collapse = Collapse.jQueryInterface
|
||||
jQueryMock.fn.collapse = getJqueryInterfaceForPlugin(Collapse)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.collapse.call(jQueryMock)
|
||||
@@ -977,7 +978,7 @@ describe('Collapse', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.collapse = Collapse.jQueryInterface
|
||||
jQueryMock.fn.collapse = getJqueryInterfaceForPlugin(Collapse)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import Dropdown from '../../src/dropdown'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { noop } from '../../src/util/index'
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Dropdown', () => {
|
||||
let fixtureEl
|
||||
@@ -2135,7 +2136,7 @@ describe('Dropdown', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.dropdown = Dropdown.jQueryInterface
|
||||
jQueryMock.fn.dropdown = getJqueryInterfaceForPlugin(Dropdown)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.dropdown.call(jQueryMock)
|
||||
@@ -2149,7 +2150,7 @@ describe('Dropdown', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const dropdown = new Dropdown(div)
|
||||
|
||||
jQueryMock.fn.dropdown = Dropdown.jQueryInterface
|
||||
jQueryMock.fn.dropdown = getJqueryInterfaceForPlugin(Dropdown)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.dropdown.call(jQueryMock)
|
||||
@@ -2163,7 +2164,7 @@ describe('Dropdown', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.dropdown = Dropdown.jQueryInterface
|
||||
jQueryMock.fn.dropdown = getJqueryInterfaceForPlugin(Dropdown)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -12,7 +12,8 @@ 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'
|
||||
import { getFixture, clearFixture } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('jQuery', () => {
|
||||
let fixtureEl
|
||||
@@ -26,18 +27,18 @@ describe('jQuery', () => {
|
||||
})
|
||||
|
||||
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)
|
||||
expect(getJqueryInterfaceForPlugin(Alert)).toEqual(jQuery.fn.alert)
|
||||
expect(getJqueryInterfaceForPlugin(Button)).toEqual(jQuery.fn.button)
|
||||
expect(getJqueryInterfaceForPlugin(Carousel)).toEqual(jQuery.fn.carousel)
|
||||
expect(getJqueryInterfaceForPlugin(Collapse)).toEqual(jQuery.fn.collapse)
|
||||
expect(getJqueryInterfaceForPlugin(Dropdown)).toEqual(jQuery.fn.dropdown)
|
||||
expect(getJqueryInterfaceForPlugin(Modal)).toEqual(jQuery.fn.modal)
|
||||
expect(getJqueryInterfaceForPlugin(Offcanvas)).toEqual(jQuery.fn.offcanvas)
|
||||
expect(getJqueryInterfaceForPlugin(Popover)).toEqual(jQuery.fn.popover)
|
||||
expect(getJqueryInterfaceForPlugin(ScrollSpy)).toEqual(jQuery.fn.scrollspy)
|
||||
expect(getJqueryInterfaceForPlugin(Tab)).toEqual(jQuery.fn.tab)
|
||||
expect(getJqueryInterfaceForPlugin(Toast)).toEqual(jQuery.fn.toast)
|
||||
expect(getJqueryInterfaceForPlugin(Tooltip)).toEqual(jQuery.fn.tooltip)
|
||||
})
|
||||
|
||||
it('should use jQuery event system', () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import Modal from '../../src/modal'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import ScrollBarHelper from '../../src/util/scrollbar'
|
||||
import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Modal', () => {
|
||||
let fixtureEl
|
||||
@@ -1100,7 +1101,7 @@ describe('Modal', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.modal = Modal.jQueryInterface
|
||||
jQueryMock.fn.modal = getJqueryInterfaceForPlugin(Modal)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.modal.call(jQueryMock)
|
||||
@@ -1113,7 +1114,7 @@ describe('Modal', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.modal = Modal.jQueryInterface
|
||||
jQueryMock.fn.modal = getJqueryInterfaceForPlugin(Modal)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.modal.call(jQueryMock, { keyboard: false })
|
||||
@@ -1131,7 +1132,7 @@ describe('Modal', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const modal = new Modal(div)
|
||||
|
||||
jQueryMock.fn.modal = Modal.jQueryInterface
|
||||
jQueryMock.fn.modal = getJqueryInterfaceForPlugin(Modal)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.modal.call(jQueryMock)
|
||||
@@ -1145,7 +1146,7 @@ describe('Modal', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.modal = Modal.jQueryInterface
|
||||
jQueryMock.fn.modal = getJqueryInterfaceForPlugin(Modal)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -1159,7 +1160,7 @@ describe('Modal', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const modal = new Modal(div)
|
||||
|
||||
jQueryMock.fn.modal = Modal.jQueryInterface
|
||||
jQueryMock.fn.modal = getJqueryInterfaceForPlugin(Modal)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
spyOn(modal, 'show')
|
||||
@@ -1174,7 +1175,7 @@ describe('Modal', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.modal = Modal.jQueryInterface
|
||||
jQueryMock.fn.modal = getJqueryInterfaceForPlugin(Modal)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
spyOn(Modal.prototype, 'show')
|
||||
|
||||
@@ -3,6 +3,7 @@ import EventHandler from '../../src/dom/event-handler'
|
||||
import { clearBodyAndDocument, clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { isVisible } from '../../src/util/index'
|
||||
import ScrollBarHelper from '../../src/util/scrollbar'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Offcanvas', () => {
|
||||
let fixtureEl
|
||||
@@ -722,7 +723,7 @@ describe('Offcanvas', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.offcanvas.call(jQueryMock)
|
||||
@@ -736,7 +737,7 @@ describe('Offcanvas', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const offCanvas = new Offcanvas(div)
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.offcanvas.call(jQueryMock)
|
||||
@@ -750,7 +751,7 @@ describe('Offcanvas', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -764,7 +765,7 @@ describe('Offcanvas', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = '_getConfig'
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -778,7 +779,7 @@ describe('Offcanvas', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'constructor'
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -793,7 +794,7 @@ describe('Offcanvas', () => {
|
||||
|
||||
spyOn(Offcanvas.prototype, 'show')
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.offcanvas.call(jQueryMock, 'show')
|
||||
@@ -805,7 +806,7 @@ describe('Offcanvas', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.offcanvas = Offcanvas.jQueryInterface
|
||||
jQueryMock.fn.offcanvas = getJqueryInterfaceForPlugin(Offcanvas)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.offcanvas.call(jQueryMock, { scroll: true })
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Popover from '../../src/popover'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { clearFixture, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Popover', () => {
|
||||
let fixtureEl
|
||||
@@ -269,7 +270,7 @@ describe('Popover', () => {
|
||||
|
||||
const popoverEl = fixtureEl.querySelector('a')
|
||||
|
||||
jQueryMock.fn.popover = Popover.jQueryInterface
|
||||
jQueryMock.fn.popover = getJqueryInterfaceForPlugin(Popover)
|
||||
jQueryMock.elements = [popoverEl]
|
||||
|
||||
jQueryMock.fn.popover.call(jQueryMock)
|
||||
@@ -282,7 +283,7 @@ describe('Popover', () => {
|
||||
|
||||
const popoverEl = fixtureEl.querySelector('a')
|
||||
|
||||
jQueryMock.fn.popover = Popover.jQueryInterface
|
||||
jQueryMock.fn.popover = getJqueryInterfaceForPlugin(Popover)
|
||||
jQueryMock.elements = [popoverEl]
|
||||
|
||||
jQueryMock.fn.popover.call(jQueryMock, {
|
||||
@@ -298,7 +299,7 @@ describe('Popover', () => {
|
||||
const popoverEl = fixtureEl.querySelector('a')
|
||||
const popover = new Popover(popoverEl)
|
||||
|
||||
jQueryMock.fn.popover = Popover.jQueryInterface
|
||||
jQueryMock.fn.popover = getJqueryInterfaceForPlugin(Popover)
|
||||
jQueryMock.elements = [popoverEl]
|
||||
|
||||
jQueryMock.fn.popover.call(jQueryMock)
|
||||
@@ -312,7 +313,7 @@ describe('Popover', () => {
|
||||
const popoverEl = fixtureEl.querySelector('a')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.popover = Popover.jQueryInterface
|
||||
jQueryMock.fn.popover = getJqueryInterfaceForPlugin(Popover)
|
||||
jQueryMock.elements = [popoverEl]
|
||||
|
||||
expect(() => {
|
||||
@@ -326,7 +327,7 @@ describe('Popover', () => {
|
||||
const popoverEl = fixtureEl.querySelector('a')
|
||||
const popover = new Popover(popoverEl)
|
||||
|
||||
jQueryMock.fn.popover = Popover.jQueryInterface
|
||||
jQueryMock.fn.popover = getJqueryInterfaceForPlugin(Popover)
|
||||
jQueryMock.elements = [popoverEl]
|
||||
|
||||
spyOn(popover, 'show')
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import ScrollSpy from '../../src/scrollspy'
|
||||
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
/** Test helpers */
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
|
||||
describe('ScrollSpy', () => {
|
||||
let fixtureEl
|
||||
@@ -610,7 +610,7 @@ describe('ScrollSpy', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('.content')
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.scrollspy.call(jQueryMock, { target: '#navBar' })
|
||||
@@ -623,7 +623,7 @@ describe('ScrollSpy', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('.content')
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.scrollspy.call(jQueryMock, { rootMargin: '100px' })
|
||||
@@ -641,7 +641,7 @@ describe('ScrollSpy', () => {
|
||||
const div = fixtureEl.querySelector('.content')
|
||||
const scrollSpy = new ScrollSpy(div)
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.scrollspy.call(jQueryMock)
|
||||
@@ -657,7 +657,7 @@ describe('ScrollSpy', () => {
|
||||
|
||||
spyOn(scrollSpy, 'refresh')
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.scrollspy.call(jQueryMock, 'refresh')
|
||||
@@ -672,7 +672,7 @@ describe('ScrollSpy', () => {
|
||||
const div = fixtureEl.querySelector('.content')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -686,7 +686,7 @@ describe('ScrollSpy', () => {
|
||||
const div = fixtureEl.querySelector('.content')
|
||||
const action = '_getConfig'
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
@@ -700,7 +700,7 @@ describe('ScrollSpy', () => {
|
||||
const div = fixtureEl.querySelector('.content')
|
||||
const action = 'constructor'
|
||||
|
||||
jQueryMock.fn.scrollspy = ScrollSpy.jQueryInterface
|
||||
jQueryMock.fn.scrollspy = getJqueryInterfaceForPlugin(ScrollSpy)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Tab from '../../src/tab'
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Tab', () => {
|
||||
let fixtureEl
|
||||
@@ -622,7 +623,7 @@ describe('Tab', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('.nav > div')
|
||||
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.fn.tab = getJqueryInterfaceForPlugin(Tab)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tab.call(jQueryMock)
|
||||
@@ -636,7 +637,7 @@ describe('Tab', () => {
|
||||
const div = fixtureEl.querySelector('.nav > div')
|
||||
const tab = new Tab(div)
|
||||
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.fn.tab = getJqueryInterfaceForPlugin(Tab)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tab.call(jQueryMock)
|
||||
@@ -652,7 +653,7 @@ describe('Tab', () => {
|
||||
|
||||
spyOn(tab, 'show')
|
||||
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.fn.tab = getJqueryInterfaceForPlugin(Tab)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tab.call(jQueryMock, 'show')
|
||||
@@ -667,7 +668,7 @@ describe('Tab', () => {
|
||||
const div = fixtureEl.querySelector('.nav > div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.tab = Tab.jQueryInterface
|
||||
jQueryMock.fn.tab = getJqueryInterfaceForPlugin(Tab)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Toast from '../../src/toast'
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Toast', () => {
|
||||
let fixtureEl
|
||||
@@ -540,7 +541,7 @@ describe('Toast', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.toast = Toast.jQueryInterface
|
||||
jQueryMock.fn.toast = getJqueryInterfaceForPlugin(Toast)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.toast.call(jQueryMock)
|
||||
@@ -554,7 +555,7 @@ describe('Toast', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const toast = new Toast(div)
|
||||
|
||||
jQueryMock.fn.toast = Toast.jQueryInterface
|
||||
jQueryMock.fn.toast = getJqueryInterfaceForPlugin(Toast)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.toast.call(jQueryMock)
|
||||
@@ -570,7 +571,7 @@ describe('Toast', () => {
|
||||
|
||||
spyOn(toast, 'show')
|
||||
|
||||
jQueryMock.fn.toast = Toast.jQueryInterface
|
||||
jQueryMock.fn.toast = getJqueryInterfaceForPlugin(Toast)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.toast.call(jQueryMock, 'show')
|
||||
@@ -585,7 +586,7 @@ describe('Toast', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.toast = Toast.jQueryInterface
|
||||
jQueryMock.fn.toast = getJqueryInterfaceForPlugin(Toast)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import Tooltip from '../../src/tooltip'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
import { noop } from '../../src/util/index'
|
||||
import { clearFixture, createEvent, getFixture, jQueryMock } from '../helpers/fixture'
|
||||
import { getJqueryInterfaceForPlugin } from '../../src/util/jquery-stuff'
|
||||
|
||||
describe('Tooltip', () => {
|
||||
let fixtureEl
|
||||
@@ -1455,7 +1456,7 @@ describe('Tooltip', () => {
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
jQueryMock.fn.tooltip = Tooltip.jQueryInterface
|
||||
jQueryMock.fn.tooltip = getJqueryInterfaceForPlugin(Tooltip)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tooltip.call(jQueryMock)
|
||||
@@ -1469,7 +1470,7 @@ describe('Tooltip', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const tooltip = new Tooltip(div)
|
||||
|
||||
jQueryMock.fn.tooltip = Tooltip.jQueryInterface
|
||||
jQueryMock.fn.tooltip = getJqueryInterfaceForPlugin(Tooltip)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tooltip.call(jQueryMock)
|
||||
@@ -1485,7 +1486,7 @@ describe('Tooltip', () => {
|
||||
|
||||
spyOn(tooltip, 'show')
|
||||
|
||||
jQueryMock.fn.tooltip = Tooltip.jQueryInterface
|
||||
jQueryMock.fn.tooltip = getJqueryInterfaceForPlugin(Tooltip)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tooltip.call(jQueryMock, 'show')
|
||||
@@ -1500,7 +1501,7 @@ describe('Tooltip', () => {
|
||||
const div = fixtureEl.querySelector('div')
|
||||
const action = 'undefinedMethod'
|
||||
|
||||
jQueryMock.fn.tooltip = Tooltip.jQueryInterface
|
||||
jQueryMock.fn.tooltip = getJqueryInterfaceForPlugin(Tooltip)
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
expect(() => {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { getJqueryInterfaceForPlugin } from '../../../src/util/jquery-stuff'
|
||||
|
||||
describe('Jquery Stuff', () => {
|
||||
const fakejQuery = { fn: {} }
|
||||
|
||||
beforeEach(() => {
|
||||
Object.defineProperty(window, 'jQuery', {
|
||||
value: fakejQuery,
|
||||
writable: true
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
window.jQuery = undefined
|
||||
})
|
||||
|
||||
describe('getJqueryInterfaceForPlugin', () => {
|
||||
it('should return a plugin jQueryInterface if exists', () => {
|
||||
const pluginMock = function () {}
|
||||
pluginMock.NAME = 'test'
|
||||
pluginMock.jQueryInterface = function () {}
|
||||
|
||||
expect(getJqueryInterfaceForPlugin(pluginMock)).toEqual(pluginMock.jQueryInterface)
|
||||
})
|
||||
|
||||
it('should return the default `defaultJQueryInterface`, if plugin jQueryInterface doesn\'t exists', () => {
|
||||
const pluginMock = function () {}
|
||||
pluginMock.NAME = 'test'
|
||||
|
||||
expect(getJqueryInterfaceForPlugin(pluginMock)).not.toEqual(pluginMock.jQueryInterface)
|
||||
expect(getJqueryInterfaceForPlugin(pluginMock)).toEqual(jasmine.any(Function))
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user