Skip to content

Commit a9b9912

Browse files
committed
fix test
1 parent 8c0c090 commit a9b9912

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

tests/unit/Metadata.spec.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
import { createApp,h } from 'vue'
2-
import { test, expect} from 'vitest'
1+
import { createApp, h } from 'vue'
2+
import { test, expect } from 'vitest'
33
import { useMetadata } from '../../src/index'
44

55
test('toFormValues', () => {
6-
const { toFormValues } = useMetadata()
7-
const a = { a: "foo", b: 1, c:null }
8-
const b = toFormValues(a)
6+
let result: any
7+
8+
// Create a Vue app to provide the proper context for the composable
9+
const app = createApp({
10+
setup() {
11+
const { toFormValues } = useMetadata()
12+
const a = { a: "foo", b: 1, c: null }
13+
const b = toFormValues(a)
14+
15+
result = { a, b }
16+
return {}
17+
},
18+
render: () => h('div')
19+
})
20+
21+
const container = document.createElement('div')
22+
app.mount(container)
923

1024
// toFormValues mutates and returns original argument
11-
expect(a === b).true
12-
expect(a.a).eq('foo')
13-
expect(a.b).eq(1)
14-
expect(a.c).eq(null)
25+
expect(result.a === result.b).toBe(true)
26+
expect(result.a.a).toBe('foo')
27+
expect(result.a.b).toBe(1)
28+
expect(result.a.c).toBe(null)
1529
})

0 commit comments

Comments
 (0)