feat: unwrap refs in toDisplayString
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { computed, ref } from '@vue/reactivity'
|
||||
import { toDisplayString } from '../src'
|
||||
|
||||
describe('toDisplayString', () => {
|
||||
@@ -20,6 +21,17 @@ describe('toDisplayString', () => {
|
||||
expect(toDisplayString(arr)).toBe(JSON.stringify(arr, null, 2))
|
||||
})
|
||||
|
||||
test('refs', () => {
|
||||
const n = ref(1)
|
||||
const np = computed(() => n.value + 1)
|
||||
expect(
|
||||
toDisplayString({
|
||||
n,
|
||||
np
|
||||
})
|
||||
).toBe(JSON.stringify({ n: 1, np: 2 }, null, 2))
|
||||
})
|
||||
|
||||
test('native objects', () => {
|
||||
const div = document.createElement('div')
|
||||
expect(toDisplayString(div)).toBe(`"[object HTMLDivElement]"`)
|
||||
|
||||
Reference in New Issue
Block a user