Skip to content

Commit ff50c42

Browse files
committed
read-only tests
1 parent c34e693 commit ff50c42

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

spec/vue_numeric.spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,50 @@ describe('vue-numeric', () => {
143143
done()
144144
})
145145
})
146+
147+
it('show span tag in read-only mode', done => {
148+
const vm = new Vue({
149+
el,
150+
data () {
151+
return {
152+
total: 100
153+
}
154+
},
155+
template: '<div><vue-numeric v-model="total" :read-only="true" read-only-class="test-class"></vue-numeric></div>',
156+
components: { VueNumeric }
157+
}).$mount()
158+
159+
Vue.nextTick(() => {
160+
expect(vm.$el.firstChild.tagName).toEqual('SPAN')
161+
const span = vm.$el.getElementsByTagName('span')[0]
162+
expect(span.textContent.trim()).toEqual('100')
163+
expect(span.className).toEqual('test-class')
164+
done()
165+
})
166+
})
167+
168+
it('show correct span tag when toggle read-only mode', done => {
169+
const vm = new Vue({
170+
el,
171+
data () {
172+
return {
173+
total: 100,
174+
readOnly: false
175+
}
176+
},
177+
template: '<div><vue-numeric v-model="total" :read-only="readOnly" read-only-class="test-class"></vue-numeric></div>',
178+
components: { VueNumeric }
179+
}).$mount()
180+
181+
vm.readOnly = true
182+
183+
Vue.nextTick(() => {
184+
expect(vm.$el.firstChild.tagName).toEqual('SPAN')
185+
const span = vm.$el.getElementsByTagName('span')[0]
186+
expect(span.textContent.trim()).toEqual('100')
187+
188+
Vue.nextTick(() => { expect(span.className).toEqual('test-class') })
189+
done()
190+
})
191+
})
146192
})

0 commit comments

Comments
 (0)