Skip to content

Commit 19c8aa8

Browse files
committed
refactor: tweak tests
1 parent 9a36bac commit 19c8aa8

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

packages/runtime-dom/__tests__/customElement.spec.ts

+24-23
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,30 @@ describe('defineCustomElement', () => {
215215
expect(el.hasAttribute('not-prop')).toBe(false)
216216
})
217217

218+
test('handle properties set before connecting', () => {
219+
const obj = { a: 1 }
220+
const E = defineCustomElement({
221+
props: {
222+
foo: String,
223+
post: Object
224+
},
225+
setup(props) {
226+
expect(props.foo).toBe('hello')
227+
expect(props.post).toBe(obj)
228+
},
229+
render() {
230+
return JSON.stringify(this.post)
231+
}
232+
})
233+
customElements.define('my-el-preconnect', E)
234+
const el = document.createElement('my-el-preconnect') as any
235+
el.foo = 'hello'
236+
el.post = obj
237+
238+
container.appendChild(el)
239+
expect(el.shadowRoot.innerHTML).toBe(JSON.stringify(obj))
240+
})
241+
218242
// https://github.com/vuejs/core/issues/6163
219243
test('handle components with no props', async () => {
220244
const E = defineCustomElement({
@@ -247,29 +271,6 @@ describe('defineCustomElement', () => {
247271
expect(el.maxAge).toBe(50)
248272
expect(el.shadowRoot.innerHTML).toBe('max age: 50/type: number')
249273
})
250-
251-
test('handle properties set before connecting', () => {
252-
const obj = {}
253-
const E = defineCustomElement({
254-
props: {
255-
foo: String,
256-
post: Object
257-
},
258-
setup(props) {
259-
expect(props.foo).toBe('hello')
260-
expect(props.post).toBe(obj)
261-
},
262-
render() {
263-
return `foo: ${this.foo}`
264-
}
265-
})
266-
customElements.define('my-el-preconnect', E)
267-
const el = document.createElement('my-el-preconnect') as any
268-
el.foo = 'hello'
269-
el.post = obj
270-
271-
container.appendChild(el)
272-
})
273274
})
274275

275276
describe('attrs', () => {

0 commit comments

Comments
 (0)