2019-03-13 15:23:50 +01:00
|
|
|
const fixtureId = 'fixture'
|
|
|
|
|
|
|
|
export const getFixture = () => {
|
2021-10-29 09:38:35 +02:00
|
|
|
let fixtureElement = document.getElementById(fixtureId)
|
|
|
|
|
|
|
|
if (!fixtureElement) {
|
|
|
|
fixtureElement = document.createElement('div')
|
|
|
|
fixtureElement.setAttribute('id', fixtureId)
|
|
|
|
fixtureElement.style.position = 'absolute'
|
|
|
|
fixtureElement.style.top = '-10000px'
|
|
|
|
fixtureElement.style.left = '-10000px'
|
|
|
|
fixtureElement.style.width = '10000px'
|
|
|
|
fixtureElement.style.height = '10000px'
|
|
|
|
document.body.append(fixtureElement)
|
2019-03-13 15:23:50 +01:00
|
|
|
}
|
|
|
|
|
2021-10-29 09:38:35 +02:00
|
|
|
return fixtureElement
|
2019-03-13 15:23:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const clearFixture = () => {
|
2021-10-29 09:38:35 +02:00
|
|
|
const fixtureElement = getFixture()
|
2019-03-13 15:23:50 +01:00
|
|
|
|
2021-10-29 09:38:35 +02:00
|
|
|
fixtureElement.innerHTML = ''
|
2019-03-13 15:23:50 +01:00
|
|
|
}
|
2019-03-25 11:32:02 +01:00
|
|
|
|
2021-10-29 09:38:35 +02:00
|
|
|
export const createEvent = (eventName, parameters = {}) => {
|
2021-12-16 12:23:17 +01:00
|
|
|
return new Event(eventName, parameters)
|
2019-03-25 11:32:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export const jQueryMock = {
|
|
|
|
elements: undefined,
|
|
|
|
fn: {},
|
|
|
|
each(fn) {
|
2021-10-29 09:38:35 +02:00
|
|
|
for (const element of this.elements) {
|
|
|
|
fn.call(element)
|
2021-07-30 08:28:51 +02:00
|
|
|
}
|
2019-03-25 11:32:02 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-25 05:50:16 +02:00
|
|
|
|
|
|
|
export const clearBodyAndDocument = () => {
|
|
|
|
const attributes = ['data-bs-padding-right', 'style']
|
|
|
|
|
2021-10-29 09:38:35 +02:00
|
|
|
for (const attribute of attributes) {
|
|
|
|
document.documentElement.removeAttribute(attribute)
|
|
|
|
document.body.removeAttribute(attribute)
|
2021-07-30 08:28:51 +02:00
|
|
|
}
|
2021-04-25 05:50:16 +02:00
|
|
|
}
|