mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
test(message, dialog, notification): reactive object is mutable
This commit is contained in:
parent
aefd856f60
commit
aa090cd6ef
@ -17,10 +17,11 @@ describe('n-dialog', () => {
|
||||
const Test = defineComponent({
|
||||
setup () {
|
||||
const dialog = useDialog()
|
||||
dialog.success({
|
||||
const dialogReactive = dialog.success({
|
||||
title: 'Test success',
|
||||
content: 'Content'
|
||||
})
|
||||
dialogReactive.style = 'color: red;'
|
||||
},
|
||||
render () {
|
||||
return null
|
||||
@ -66,7 +67,9 @@ describe('n-dialog', () => {
|
||||
return null
|
||||
}
|
||||
})
|
||||
const wrapper = await mount(() => <Provider>{{ default: () => <Test /> }}</Provider>)
|
||||
const wrapper = await mount(() => (
|
||||
<Provider>{{ default: () => <Test /> }}</Provider>
|
||||
))
|
||||
expect(document.querySelector('.n-button__icon')).not.toEqual(null)
|
||||
wrapper.unmount()
|
||||
})
|
||||
@ -87,7 +90,9 @@ describe('n-dialog', () => {
|
||||
return null
|
||||
}
|
||||
})
|
||||
const wrapper = mount(() => <Provider>{{ default: () => <Test /> }}</Provider>)
|
||||
const wrapper = mount(() => (
|
||||
<Provider>{{ default: () => <Test /> }}</Provider>
|
||||
))
|
||||
document.body.dispatchEvent(mousedownEvent)
|
||||
document.body.dispatchEvent(mouseupEvent)
|
||||
await nextTick(() => {
|
||||
@ -113,7 +118,9 @@ describe('n-dialog', () => {
|
||||
return null
|
||||
}
|
||||
})
|
||||
const wrapper = await mount(() => <Provider>{{ default: () => <Test /> }}</Provider>)
|
||||
const wrapper = await mount(() => (
|
||||
<Provider>{{ default: () => <Test /> }}</Provider>
|
||||
))
|
||||
document.body.dispatchEvent(mousedownEvent)
|
||||
document.body.dispatchEvent(mouseupEvent)
|
||||
expect(onMaskClick).toHaveBeenCalled()
|
||||
@ -136,8 +143,12 @@ describe('n-dialog', () => {
|
||||
return null
|
||||
}
|
||||
})
|
||||
const wrapper = await mount(() => <Provider>{{ default: () => <Test /> }}</Provider>)
|
||||
expect(document.querySelector('.n-dialog')?.getAttribute('style')).toContain('color: rgb(79, 178, 51);')
|
||||
const wrapper = await mount(() => (
|
||||
<Provider>{{ default: () => <Test /> }}</Provider>
|
||||
))
|
||||
expect(
|
||||
document.querySelector('.n-dialog')?.getAttribute('style')
|
||||
).toContain('color: rgb(79, 178, 51);')
|
||||
wrapper.unmount()
|
||||
})
|
||||
})
|
||||
|
@ -17,7 +17,8 @@ describe('n-message', () => {
|
||||
setup () {
|
||||
const message = useMessage()
|
||||
message.info('string')
|
||||
message.info(() => 'string')
|
||||
const messageReactive = message.info(() => 'string')
|
||||
messageReactive.content = '123'
|
||||
},
|
||||
render () {
|
||||
return null
|
||||
@ -133,7 +134,9 @@ describe('message-provider', () => {
|
||||
void nextTick(() => {
|
||||
const container = document.querySelector('.n-message-container')
|
||||
expect(container).not.toBe(null)
|
||||
expect(container.attributes.style.value).toContain('padding: 24px')
|
||||
expect((container as HTMLElement).style.cssText).toContain(
|
||||
'padding: 24px'
|
||||
)
|
||||
wrapper.unmount()
|
||||
done()
|
||||
})
|
||||
|
@ -23,9 +23,10 @@ describe('n-notification', () => {
|
||||
notification.info({
|
||||
title: 'info'
|
||||
})
|
||||
notification.success({
|
||||
const notificationReactive = notification.success({
|
||||
title: 'success'
|
||||
})
|
||||
notificationReactive.title = 'cool'
|
||||
},
|
||||
render () {
|
||||
return null
|
||||
|
Loading…
Reference in New Issue
Block a user