[improvement] rename packages dir to src (#3659)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`renders demo correctly 1`] = `
|
||||
<div>
|
||||
<div>
|
||||
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 30px;">
|
||||
<div class="van-switch__node"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div role="switch" aria-checked="true" class="van-switch van-switch--on van-switch--disabled" style="font-size: 30px;">
|
||||
<div class="van-switch__node"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 30px;">
|
||||
<div class="van-switch__node">
|
||||
<div class="van-loading van-loading--circular van-switch__loading"><span class="van-loading__spinner van-loading__spinner--circular" style="color: rgb(25, 137, 250);"><svg viewBox="25 25 50 50" class="van-loading__circular"><circle cx="50" cy="50" r="20" fill="none"></circle></svg></span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 24px;">
|
||||
<div class="van-switch__node"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 30px; background-color: rgb(7, 193, 96);">
|
||||
<div class="van-switch__node"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 30px;">
|
||||
<div class="van-switch__node"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -0,0 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`inactive-color prop 1`] = `
|
||||
<div role="switch" aria-checked="false" class="van-switch" style="font-size: 30px; background-color: black;">
|
||||
<div class="van-switch__node"></div>
|
||||
</div>
|
||||
`;
|
||||
@@ -0,0 +1,4 @@
|
||||
import Demo from '../demo';
|
||||
import demoTest from '../../../test/demo-test';
|
||||
|
||||
demoTest(Demo);
|
||||
@@ -0,0 +1,74 @@
|
||||
import Switch from '..';
|
||||
import { mount } from '../../../test/utils';
|
||||
|
||||
test('emit event', () => {
|
||||
const input = jest.fn();
|
||||
const change = jest.fn();
|
||||
const wrapper = mount(Switch, {
|
||||
context: {
|
||||
on: {
|
||||
input,
|
||||
change
|
||||
}
|
||||
}
|
||||
});
|
||||
wrapper.trigger('click');
|
||||
|
||||
expect(input).toHaveBeenCalledWith(true);
|
||||
expect(change).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
test('disabled', () => {
|
||||
const input = jest.fn();
|
||||
const change = jest.fn();
|
||||
const wrapper = mount(Switch, {
|
||||
context: {
|
||||
on: {
|
||||
input,
|
||||
change
|
||||
}
|
||||
},
|
||||
propsData: {
|
||||
disabled: true
|
||||
}
|
||||
});
|
||||
wrapper.trigger('click');
|
||||
|
||||
expect(input).toHaveBeenCalledTimes(0);
|
||||
expect(change).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test('active-value & inactive-value prop', () => {
|
||||
const input = jest.fn();
|
||||
const change = jest.fn();
|
||||
const wrapper = mount(Switch, {
|
||||
propsData: {
|
||||
value: '1',
|
||||
activeValue: '1',
|
||||
inactiveValue: '2'
|
||||
},
|
||||
context: {
|
||||
on: {
|
||||
input,
|
||||
change
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.trigger('click');
|
||||
|
||||
expect(input).toHaveBeenCalledWith('2');
|
||||
expect(change).toHaveBeenCalledWith('2');
|
||||
});
|
||||
|
||||
test('inactive-color prop', () => {
|
||||
const wrapper = mount(Switch, {
|
||||
propsData: {
|
||||
value: '2',
|
||||
inactiveValue: '2',
|
||||
inactiveColor: 'black'
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
Reference in New Issue
Block a user