Skip to content

Commit

Permalink
refactor: tweak tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 11, 2022
1 parent 9a36bac commit 19c8aa8
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions packages/runtime-dom/__tests__/customElement.spec.ts
Expand Up @@ -215,6 +215,30 @@ describe('defineCustomElement', () => {
expect(el.hasAttribute('not-prop')).toBe(false)
})

test('handle properties set before connecting', () => {
const obj = { a: 1 }
const E = defineCustomElement({
props: {
foo: String,
post: Object
},
setup(props) {
expect(props.foo).toBe('hello')
expect(props.post).toBe(obj)
},
render() {
return JSON.stringify(this.post)
}
})
customElements.define('my-el-preconnect', E)
const el = document.createElement('my-el-preconnect') as any
el.foo = 'hello'
el.post = obj

container.appendChild(el)
expect(el.shadowRoot.innerHTML).toBe(JSON.stringify(obj))
})

// https://github.com/vuejs/core/issues/6163
test('handle components with no props', async () => {
const E = defineCustomElement({
Expand Down Expand Up @@ -247,29 +271,6 @@ describe('defineCustomElement', () => {
expect(el.maxAge).toBe(50)
expect(el.shadowRoot.innerHTML).toBe('max age: 50/type: number')
})

test('handle properties set before connecting', () => {
const obj = {}
const E = defineCustomElement({
props: {
foo: String,
post: Object
},
setup(props) {
expect(props.foo).toBe('hello')
expect(props.post).toBe(obj)
},
render() {
return `foo: ${this.foo}`
}
})
customElements.define('my-el-preconnect', E)
const el = document.createElement('my-el-preconnect') as any
el.foo = 'hello'
el.post = obj

container.appendChild(el)
})
})

describe('attrs', () => {
Expand Down

0 comments on commit 19c8aa8

Please sign in to comment.