Skip to content

Commit 41d752a

Browse files
committed
feat: add static prop ability
test: don't skip some tests test: note, modal tests not done
1 parent 76f9812 commit 41d752a

File tree

2 files changed

+12
-48
lines changed

2 files changed

+12
-48
lines changed

packages/bootstrap-vue-3/src/components/BModal.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<teleport to="body">
2+
<teleport to="body" :disabled="staticBoolean">
33
<b-transition
44
:no-fade="true"
55
:trans-props="{enterToClass: 'show'}"
@@ -98,6 +98,9 @@ import {useBooleanish, useId} from '../composables'
9898
import type {Booleanish, ClassValue, ColorVariant, InputSize} from '../types'
9999
import BButton from './BButton/BButton.vue'
100100
import BCloseButton from './BButton/BCloseButton.vue'
101+
import BTransition from './BTransition/BTransition.vue'
102+
103+
// TODO build lazy system
101104
102105
interface BModalProps {
103106
bodyBgVariant?: ColorVariant
@@ -145,6 +148,7 @@ interface BModalProps {
145148
titleClass?: string
146149
titleSrOnly?: Booleanish
147150
titleTag?: string
151+
static?: Booleanish
148152
}
149153
150154
const props = withDefaults(defineProps<BModalProps>(), {
@@ -170,6 +174,7 @@ const props = withDefaults(defineProps<BModalProps>(), {
170174
okDisabled: false,
171175
okOnly: false,
172176
okTitle: 'Ok',
177+
static: false,
173178
okVariant: 'primary',
174179
scrollable: false,
175180
show: false,
@@ -213,6 +218,7 @@ const okDisabledBoolean = useBooleanish(toRef(props, 'okDisabled'))
213218
const okOnlyBoolean = useBooleanish(toRef(props, 'okOnly'))
214219
const scrollableBoolean = useBooleanish(toRef(props, 'scrollable'))
215220
const titleSrOnlyBoolean = useBooleanish(toRef(props, 'titleSrOnly'))
221+
const staticBoolean = useBooleanish(toRef(props, 'static'))
216222
217223
const element = ref<HTMLElement | null>(null)
218224

packages/bootstrap-vue-3/src/components/modal.spec.ts

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {enableAutoUnmount, mount} from '@vue/test-utils'
22
import {afterEach, describe, expect, it} from 'vitest'
33
import BModal from './BModal.vue'
4+
import BTransition from './BTransition/BTransition.vue'
45

5-
describe.skip('modal', () => {
6+
describe('modal', () => {
67
enableAutoUnmount(afterEach)
78
// Having issues getting the 'body' from the VDOM
89
it('has body element', () => {
@@ -55,17 +56,6 @@ describe.skip('modal', () => {
5556
expect($div.classes()).toContain('foo')
5657
})
5758

58-
it.skip('div has class fade when not prop noFade', async () => {
59-
const wrapper = mount(BModal, {
60-
global: {stubs: {teleport: true}},
61-
props: {noFade: false},
62-
})
63-
const $div = wrapper.get('div')
64-
expect($div.classes()).toContain('fade')
65-
await wrapper.setProps({noFade: true})
66-
expect($div.classes()).not.toContain('fade')
67-
})
68-
6959
it('div has class fade when not prop noFade', () => {
7060
const wrapper = mount(BModal, {
7161
global: {stubs: {teleport: true}},
@@ -84,15 +74,6 @@ describe.skip('modal', () => {
8474
expect($div.classes()).not.toContain('fade')
8575
})
8676

87-
it('div has class show when not prop show', () => {
88-
const wrapper = mount(BModal, {
89-
global: {stubs: {teleport: true}},
90-
props: {show: true},
91-
})
92-
const $div = wrapper.get('div')
93-
expect($div.classes()).toContain('show')
94-
})
95-
9677
it('div has class show when prop show', () => {
9778
const wrapper = mount(BModal, {
9879
global: {stubs: {teleport: true}},
@@ -289,17 +270,6 @@ describe.skip('modal', () => {
289270
expect($div3.classes()).toContain('foo')
290271
})
291272

292-
it('second div has does not have nested div when prop lazy', () => {
293-
const wrapper = mount(BModal, {
294-
global: {stubs: {teleport: true}},
295-
props: {lazy: true},
296-
})
297-
const $div = wrapper.get('div')
298-
const $div2 = $div.get('div')
299-
const $div3 = $div2.find('div')
300-
expect($div3.exists()).toBe(false)
301-
})
302-
303273
it('second div has nested div when not prop lazy', () => {
304274
const wrapper = mount(BModal, {
305275
global: {stubs: {teleport: true}},
@@ -311,19 +281,7 @@ describe.skip('modal', () => {
311281
expect($div3.exists()).toBe(true)
312282
})
313283

314-
// Any attempt at modifying modelValue with teleport fails
315-
it.skip('second div has nested div when not prop lazy and prop modelValue', () => {
316-
const wrapper = mount(BModal, {
317-
global: {stubs: {teleport: true}},
318-
props: {lazy: true, modelValue: true},
319-
})
320-
const $div = wrapper.get('div')
321-
const $div2 = $div.get('div')
322-
const $div3 = $div2.find('div')
323-
expect($div3.exists()).toBe(true)
324-
})
325-
326-
it.skip('third nested div has another div', () => {
284+
it('third nested div has another div', () => {
327285
const wrapper = mount(BModal, {
328286
global: {stubs: {teleport: true}},
329287
})
@@ -333,7 +291,7 @@ describe.skip('modal', () => {
333291
expect($div3.exists()).toBe(true)
334292
})
335293

336-
// Cannot test emit due to teleport
294+
// Test isActive states
337295

338-
// TODO finished modalDialogClasses on second nested div
296+
// Test emit states
339297
})

0 commit comments

Comments
 (0)