[Improvement] Picker: optimize render performance (#1391)

This commit is contained in:
neverland
2018-07-03 23:36:36 +08:00
committed by GitHub
parent 6adf501441
commit 7f4ad6a28d
5 changed files with 50 additions and 64 deletions

View File

@@ -1,6 +1,6 @@
import Picker from '../';
import PickerColumn from '../PickerColumn';
import { mount, triggerDrag } from '../../../test/utils';
import { mount, triggerDrag, later } from '../../../test/utils';
const simpleColumn = ['1990', '1991', '1992', '1993', '1994', '1995'];
const columns = [
@@ -101,21 +101,19 @@ test('drag simple columns', () => {
expect(wrapper.emitted('change')[0][1]).toEqual('1992');
});
test('column watch default index', () => {
test('column watch default index', async() => {
const disabled = { disabled: true, text: 1 };
const wrapper = mount(PickerColumn, {
propsData: {
initialOptions: [disabled, ...simpleColumn],
valueKey: 'text',
itemHeight: 50
}
});
wrapper.vm.options = [disabled, ...simpleColumn];
await later();
expect(wrapper).toMatchSnapshot();
wrapper.vm.options = [disabled, ...simpleColumn];
expect(wrapper).toMatchSnapshot();
wrapper.vm.options = [1, disabled, disabled, disabled];
wrapper.vm.defaultIndex = 2;
expect(wrapper).toMatchSnapshot();
});