import Vue from 'vue';
import Radio from '..';
import RadioGroup from '../../radio-group';
import { mount } from '../../../test/utils';
Vue.use(Radio);
Vue.use(RadioGroup);
test('radio-group change', () => {
const wrapper = mount({
template: `
label
`,
data() {
return {
result: 'a',
list: ['a', 'b', 'c', 'd']
};
}
});
const icons = wrapper.findAll('.van-radio__icon');
const labels = wrapper.findAll('.van-radio__label');
icons.at(2).trigger('click');
expect(wrapper.vm.result).toEqual('c');
expect(wrapper.emitted('change')[0][0]).toEqual('c');
labels.at(1).trigger('click');
expect(wrapper.vm.result).toEqual('b');
expect(wrapper.emitted('change')[1][0]).toEqual('b');
icons.at(3).trigger('click');
labels.at(3).trigger('click');
expect(wrapper.vm.result).toEqual('b');
});
test('radio group disabled', () => {
const wrapper = mount({
template: `
label
`,
data() {
return {
result: 'a',
list: ['a', 'b', 'c', 'd']
};
}
});
const icons = wrapper.findAll('.van-radio__icon');
icons.at(2).trigger('click');
expect(wrapper.emitted('change')).toBeFalsy();
});
test('icon-size prop', () => {
const wrapper = mount({
template: `
label
label
`
});
expect(wrapper).toMatchSnapshot();
});
test('checked-color prop', () => {
const wrapper = mount({
template: `
label
label
`
});
expect(wrapper).toMatchSnapshot();
});