Sha256: 3fcae11b812ab1b98808635f122b35b05e53bfa59e1478182a148865cea79b8d

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

const fixtureId = 'fixture'

export const getFixture = () => {
  let fixtureEl = document.getElementById(fixtureId)

  if (!fixtureEl) {
    fixtureEl = document.createElement('div')
    fixtureEl.setAttribute('id', fixtureId)
    fixtureEl.style.position = 'absolute'
    fixtureEl.style.top = '-10000px'
    fixtureEl.style.left = '-10000px'
    fixtureEl.style.width = '10000px'
    fixtureEl.style.height = '10000px'
    document.body.append(fixtureEl)
  }

  return fixtureEl
}

export const clearFixture = () => {
  const fixtureEl = getFixture()

  fixtureEl.innerHTML = ''
}

export const createEvent = (eventName, params = {}) => {
  const event = document.createEvent('Event')

  event.initEvent(eventName, Boolean(params.bubbles), Boolean(params.cancelable))
  return event
}

export const jQueryMock = {
  elements: undefined,
  fn: {},
  each(fn) {
    this.elements.forEach(el => {
      fn.call(el)
    })
  }
}

export const clearBodyAndDocument = () => {
  const attributes = ['data-bs-padding-right', 'style']

  attributes.forEach(attr => {
    document.documentElement.removeAttribute(attr)
    document.body.removeAttribute(attr)
  })
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-mod-bootstrap-0.18.1 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.18.0 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.17.0 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.16.0 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.6 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.5 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.4 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.3 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.1.2 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.2.pre1 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.1.1 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.1 vendor/bootstrap/js/tests/helpers/fixture.js
card-mod-bootstrap-0.15.0 vendor/bootstrap/js/tests/helpers/fixture.js