1
0
mirror of synced 2024-11-22 21:36:04 +03:00
vue-formulario/test/unit/Formulario.test.js
2020-10-19 13:45:20 +03:00

37 lines
1016 B
JavaScript

import Formulario from '@/index.ts'
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)
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')
})
})