blob: 5ad14e1db9dd9876bcf34246bfb9fb0a17a0c04b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
const fixtureId = 'fixture'
export const getFixture = () => {
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)
}
return fixtureElement
}
export const clearFixture = () => {
const fixtureElement = getFixture()
fixtureElement.innerHTML = ''
}
export const createEvent = (eventName, parameters = {}) => {
return new Event(eventName, parameters)
}
export const jQueryMock = {
elements: undefined,
fn: {},
each(fn) {
for (const element of this.elements) {
fn.call(element)
}
}
}
export const clearBodyAndDocument = () => {
const attributes = ['data-bs-padding-right', 'style']
for (const attribute of attributes) {
document.documentElement.removeAttribute(attribute)
document.body.removeAttribute(attribute)
}
}
|