2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-08 17:22:31 +03:00

Variabilize backdrop class name (#34094)

This commit is contained in:
Romain
2021-05-31 19:14:54 +02:00
committed by GeoSot
parent 088ef62982
commit 93f1107ef5
5 changed files with 39 additions and 16 deletions
+28 -13
View File
@@ -3,6 +3,7 @@ import { getTransitionDurationFromElement } from '../../../src/util/index'
import { clearFixture, getFixture } from '../../helpers/fixture'
const CLASS_BACKDROP = '.modal-backdrop'
const CLASS_NAME_BACKDROP = 'modal-backdrop'
const CLASS_NAME_FADE = 'fade'
const CLASS_NAME_SHOW = 'show'
@@ -26,7 +27,8 @@ describe('Backdrop', () => {
it('if it is "shown", should append the backdrop html once, on show, and contain "show" class', done => {
const instance = new Backdrop({
isVisible: true,
isAnimated: false
isAnimated: false,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
@@ -45,7 +47,8 @@ describe('Backdrop', () => {
it('if it is not "shown", should not append the backdrop html', done => {
const instance = new Backdrop({
isVisible: false,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
@@ -59,7 +62,8 @@ describe('Backdrop', () => {
it('if it is "shown" and "animated", should append the backdrop html once, and contain "fade" class', done => {
const instance = new Backdrop({
isVisible: true,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
@@ -79,7 +83,8 @@ describe('Backdrop', () => {
it('should remove the backdrop html', done => {
const instance = new Backdrop({
isVisible: true,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElements = () => document.body.querySelectorAll(CLASS_BACKDROP)
@@ -97,7 +102,8 @@ describe('Backdrop', () => {
it('should remove "show" class', done => {
const instance = new Backdrop({
isVisible: true,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const elem = instance._getElement()
@@ -111,7 +117,8 @@ describe('Backdrop', () => {
it('if it is not "shown", should not try to remove Node on remove method', done => {
const instance = new Backdrop({
isVisible: false,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
const spy = spyOn(instance, 'dispose').and.callThrough()
@@ -135,7 +142,8 @@ describe('Backdrop', () => {
const instance = new Backdrop({
isVisible: true,
isAnimated: true,
rootElement: wrapper
rootElement: wrapper,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElements = () => document.querySelectorAll(CLASS_BACKDROP)
@@ -157,6 +165,7 @@ describe('Backdrop', () => {
const instance = new Backdrop({
isVisible: true,
isAnimated: false,
backdropClassName: CLASS_NAME_BACKDROP,
clickCallback: () => spy()
})
const endTest = () => {
@@ -179,7 +188,8 @@ describe('Backdrop', () => {
it('if it is animated, should show and hide backdrop after counting transition duration', done => {
const instance = new Backdrop({
isVisible: true,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const spy2 = jasmine.createSpy('spy2')
@@ -202,7 +212,8 @@ describe('Backdrop', () => {
const spy = jasmine.createSpy('spy', getTransitionDurationFromElement)
const instance = new Backdrop({
isVisible: true,
isAnimated: false
isAnimated: false,
backdropClassName: CLASS_NAME_BACKDROP
})
const spy2 = jasmine.createSpy('spy2')
@@ -219,7 +230,8 @@ describe('Backdrop', () => {
it('if it is not "shown", should not call delay callbacks', done => {
const instance = new Backdrop({
isVisible: false,
isAnimated: true
isAnimated: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const spy = jasmine.createSpy('spy', getTransitionDurationFromElement)
@@ -234,7 +246,8 @@ describe('Backdrop', () => {
describe('rootElement initialization', () => {
it('Should be appended on "document.body" by default', done => {
const instance = new Backdrop({
isVisible: true
isVisible: true,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElement = () => document.querySelector(CLASS_BACKDROP)
instance.show(() => {
@@ -246,7 +259,8 @@ describe('Backdrop', () => {
it('Should find the rootElement if passed as a string', done => {
const instance = new Backdrop({
isVisible: true,
rootElement: 'body'
rootElement: 'body',
backdropClassName: CLASS_NAME_BACKDROP
})
const getElement = () => document.querySelector(CLASS_BACKDROP)
instance.show(() => {
@@ -264,7 +278,8 @@ describe('Backdrop', () => {
const wrapper = fixtureEl.querySelector('#wrapper')
const instance = new Backdrop({
isVisible: true,
rootElement: wrapper
rootElement: wrapper,
backdropClassName: CLASS_NAME_BACKDROP
})
const getElement = () => document.querySelector(CLASS_BACKDROP)
instance.show(() => {