Skip to content

Commit

Permalink
test: add use case of #43
Browse files Browse the repository at this point in the history
  • Loading branch information
imyelo committed Jun 19, 2019
1 parent 68017e0 commit 486e5b1
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/cases/backward/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,43 @@ test.serial('`this.getRelationNodes` method should exist', async (t) => {
await component._emit('attached')
t.true(spy.lastCall.calledWithExactly(sinon.match.func))
})

/**
* https://github.com/tinajs/tina/issues/43
*/
test.serial('`data` should not be shared between component', async (t) => {
const spy = sinon.spy()
const options = {
data: {
foo: {
bar: 'baz',
},
},
attached () {
this.input('qux')
},
methods: {
input (value) {
this.data.foo['bar'] = value
this.setData({
foo: this.data.foo,
})
},
},
}
Tina.Component.define(options)
Tina.Component.define(options)

const components = [
t.context.mina.getComponent(-1),
t.context.mina.getComponent(-2),
]

await components[0]._emit('created')
await components[1]._emit('created')

await components[0]._emit('attached')

t.is(components[0].data.foo.bar, 'qux')
t.is(components[1].data.foo.bar, 'baz')
})

0 comments on commit 486e5b1

Please sign in to comment.