1
0
mirror of synced 2024-11-24 22:36:02 +03:00
vue-formulario/test/unit/Formulario.test.js

37 lines
1016 B
JavaScript
Raw Normal View History

import Formulario from '@/index.ts'
2020-05-22 14:22:16 +03:00
describe('Formulario', () => {
it('installs on vue instance', () => {
const components = [
'FormularioForm',
'FormularioInput',
'FormularioGrouping',
]
const registry = []
function Vue () {}
Vue.component = function (name, instance) {
registry.push(name)
}
Formulario.install(Vue)
2020-05-22 14:22:16 +03:00
expect(Vue.prototype.$formulario).toBe(Formulario)
expect(registry).toEqual(components)
})
it('can extend instance in a plugin', () => {
function Vue () {}
Vue.component = function (name, instance) {}
const plugin = function (i) {
i.extend({
rules: {
testRule: () => false
}
})
}
Formulario.install(Vue, {
plugins: [ plugin ]
})
expect(typeof Vue.prototype.$formulario.options.rules.testRule).toBe('function')
})
})