test: add multi-store test case

This commit is contained in:
dntzhang 2019-10-12 09:39:28 +08:00
parent 07e48979c7
commit f4a0f40488
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,38 @@
<template>
<div id="app">
<span class="count">{{ state.cs.count }}</span>
<button id="btn" @click="store.cs.sub">sub</button>
</div>
</template>
<script>
import { $ } from '../../../src/omiv'
const cs = new class {
data = {
count: 2
}
sub = () => {
this.data.count--
}
add = () => {
this.data.count++
}
}
const rs = new class {
data = {
name: 'omiv'
}
rename = () => {
this.data.name = 'omiv + vue'
}
}
export default $({
store: { cs, rs },
use: {
cs: ['count']
}
})
</script>

View File

@ -70,6 +70,22 @@ describe('base', () => {
})
})
it('multi-store test', (done) => {
new Vue({
render: h => h(require('./components/multi-store.vue')
.default)
}).$mount('#app')
document.querySelector('#btn').click()
Vue.nextTick(() => {
done()
expect(document.querySelector('#app').innerHTML)
.to.equal('<span class="count">1</span> <button id="btn">sub</button>')
})
})
})