2019-11-14 09:00:56 +03:00
|
|
|
import Vue from 'vue'
|
|
|
|
import { mount } from '@vue/test-utils'
|
2020-03-07 17:03:59 +03:00
|
|
|
import Formulate from '@/Formulate.js'
|
|
|
|
import FormulateInput from '@/FormulateInput.vue'
|
|
|
|
import FormulateInputSlider from '@/inputs/FormulateInputSlider.vue'
|
2019-11-14 09:00:56 +03:00
|
|
|
|
|
|
|
Vue.use(Formulate)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test each type of slider element
|
|
|
|
*/
|
|
|
|
|
|
|
|
describe('FormulateInputSlider', () => {
|
|
|
|
it('renders range input when type is "range"', () => {
|
|
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'range' } })
|
2020-05-14 23:08:54 +03:00
|
|
|
expect(wrapper.findComponent(FormulateInputSlider).exists()).toBe(true)
|
2019-11-14 09:00:56 +03:00
|
|
|
})
|
2020-02-27 09:18:51 +03:00
|
|
|
|
|
|
|
it('does not show value if the show-value prop is not set', () => {
|
|
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'range', value: '15', min: '0', max: '100' } })
|
|
|
|
expect(wrapper.find('.formulate-input-element-range-value').exists()).toBe(false)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('renders the value when type is "range" and show-value prop is set', () => {
|
|
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'range', showValue: 'true', value: '15', min: '0', max: '100' } })
|
|
|
|
expect(wrapper.find('.formulate-input-element-range-value').text()).toBe('15')
|
|
|
|
})
|
2020-05-01 21:57:30 +03:00
|
|
|
|
|
|
|
it('passes an explicitly given name prop through to the root element', () => {
|
|
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'range', name: 'foo' } })
|
|
|
|
expect(wrapper.find('input[name="foo"]').exists()).toBe(true)
|
|
|
|
})
|
2020-05-01 22:42:47 +03:00
|
|
|
|
|
|
|
it('additional context does not bleed through to range input attributes', () => {
|
|
|
|
const wrapper = mount(FormulateInput, { propsData: { type: 'range' } } )
|
|
|
|
expect(Object.keys(wrapper.find('input[type="range"]').attributes())).toEqual(["type", "id"])
|
|
|
|
})
|
2019-11-14 09:00:56 +03:00
|
|
|
})
|