🌐 AI搜索 & 代理 主页
Skip to content

Commit 0119ef8

Browse files
committed
Update popover.spec.js
1 parent fa7d792 commit 0119ef8

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/components/popover/popover.spec.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ const App = {
3232
h(
3333
BPopover,
3434
{
35-
attrs: { id: 'bar' },
35+
attrs: {
36+
id: 'bar',
37+
'data-foo': 'bar'
38+
},
3639
props: {
3740
target: 'foo',
3841
triggers: this.triggers,
@@ -156,20 +159,22 @@ describe('b-popover', () => {
156159
expect($button.attributes('id')).toEqual('foo')
157160
expect($button.attributes('data-original-title')).not.toBeDefined()
158161
// ID of the tooltip that will be in the body
159-
const adb = $button.attributes('aria-describedby')
162+
const $adb = $button.attributes('aria-describedby')
160163

161164
// <b-popover> wrapper
162165
const $tipHolder = wrapper.findComponent(BPopover)
163166
expect($tipHolder.exists()).toBe(true)
164167
expect($tipHolder.element.nodeType).toEqual(Node.COMMENT_NODE)
165168

166169
// Find the popover element in the document
167-
const tip = document.getElementById(adb)
168-
expect(tip).not.toBe(null)
169-
expect(tip).toBeInstanceOf(HTMLElement)
170-
expect(tip.tagName).toEqual('DIV')
171-
expect(tip.classList.contains('popover')).toBe(true)
172-
expect(tip.classList.contains('b-popover')).toBe(true)
170+
const $tip = document.getElementById($adb)
171+
expect($tip).not.toBe(null)
172+
expect($tip).toBeInstanceOf(HTMLElement)
173+
expect($tip.tagName).toEqual('DIV')
174+
expect($tip.getAttribute('id')).toEqual('bar')
175+
expect($tip.getAttribute('data-foo')).toEqual('bar')
176+
expect($tip.classList.contains('popover')).toBe(true)
177+
expect($tip.classList.contains('b-popover')).toBe(true)
173178

174179
// Hide the Popover
175180
await wrapper.setProps({
@@ -184,8 +189,8 @@ describe('b-popover', () => {
184189
expect($button.attributes('aria-describedby')).not.toBeDefined()
185190

186191
// Popover element should not be in the document
187-
expect(document.body.contains(tip)).toBe(false)
188-
expect(document.getElementById(adb)).toBe(null)
192+
expect(document.body.contains($tip)).toBe(false)
193+
expect(document.getElementById($adb)).toBe(null)
189194

190195
wrapper.destroy()
191196
})

0 commit comments

Comments
 (0)