diff --git a/packages/vant/src/address-edit/AddressEdit.tsx b/packages/vant/src/address-edit/AddressEdit.tsx
index fa4ba1048..392a4b166 100644
--- a/packages/vant/src/address-edit/AddressEdit.tsx
+++ b/packages/vant/src/address-edit/AddressEdit.tsx
@@ -198,7 +198,7 @@ export default defineComponent({
Toast(t('areaEmpty'));
} else {
showAreaPopup.value = false;
- assignAreaText(selectedOptions);
+ assignAreaText(selectedOptions as PickerOption[]);
emit('changeArea', selectedOptions);
}
};
@@ -257,9 +257,11 @@ export default defineComponent({
const options = areaRef.value?.getSelectedOptions();
if (
options &&
- options.every((option) => option.value !== AREA_EMPTY_CODE)
+ options.every(
+ (option) => option && option.value !== AREA_EMPTY_CODE
+ )
) {
- assignAreaText(options);
+ assignAreaText(options as PickerOption[]);
}
});
},
diff --git a/packages/vant/src/address-edit/test/__snapshots__/demo.spec.ts.snap b/packages/vant/src/address-edit/test/__snapshots__/demo.spec.ts.snap
new file mode 100644
index 000000000..cfbf956f8
--- /dev/null
+++ b/packages/vant/src/address-edit/test/__snapshots__/demo.spec.ts.snap
@@ -0,0 +1,148 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render demo and match snapshot 1`] = `
+
+`;
diff --git a/packages/vant/src/address-edit/test/__snapshots__/index.spec.js.snap b/packages/vant/src/address-edit/test/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..1e95a6876
--- /dev/null
+++ b/packages/vant/src/address-edit/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,373 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should allow to custom validator with validator prop 1`] = `
+
+ foo name
+
+`;
+
+exports[`should render AddressEdit correctly 1`] = `
+
+`;
+
+exports[`should render AddressEdit with props correctly 1`] = `
+
+`;
+
+exports[`should valid address detail and render error message correctly 1`] = `
+
+
+
+
+
+
+
+
+
+ Address can not be empty
+
+
+
+`;
+
+exports[`should valid area code and render error message correctly 1`] = `
+
+`;
+
+exports[`should valid name and render error message correctly 1`] = `
+
+
+
+
+
+
+
+
+
+ Please fill in the name
+
+
+
+`;
+
+exports[`should valid postal code and render error message correctly 1`] = `
+
+
+
+
+
+
+
+
+
+ Wrong postal code
+
+
+
+`;
+
+exports[`should valid tel and render error message correctly 1`] = `
+
+
+
+
+
+
+
+
+
+ Malformed phone number
+
+
+
+`;
diff --git a/packages/vant/src/address-edit/test/demo.legacy.ts b/packages/vant/src/address-edit/test/demo.spec.ts
similarity index 100%
rename from packages/vant/src/address-edit/test/demo.legacy.ts
rename to packages/vant/src/address-edit/test/demo.spec.ts
diff --git a/packages/vant/src/address-edit/test/index.legacy.js b/packages/vant/src/address-edit/test/index.spec.js
similarity index 88%
rename from packages/vant/src/address-edit/test/index.legacy.js
rename to packages/vant/src/address-edit/test/index.spec.js
index f44e7adf8..323d04b4b 100644
--- a/packages/vant/src/address-edit/test/index.legacy.js
+++ b/packages/vant/src/address-edit/test/index.spec.js
@@ -121,32 +121,6 @@ test('should emit changeDetail event after changing address detail', () => {
expect(wrapper.emitted('changeDetail')[0][0]).toEqual('123');
});
-test('should return current areas after calling getArea method', () => {
- const wrapper = mount(AddressEdit, {
- props: { areaList },
- });
-
- expect(wrapper.vm.getArea()).toEqual([
- { code: '110000', name: '北京市' },
- { code: '110100', name: '北京市' },
- { code: '110101', name: '东城区' },
- ]);
-});
-
-test('should update current areas after calling setAreaCode method', async () => {
- const wrapper = mount(AddressEdit, {
- props: { areaList },
- });
-
- wrapper.vm.setAreaCode('110102');
- await later();
- expect(wrapper.vm.getArea()).toEqual([
- { code: '110000', name: '北京市' },
- { code: '110100', name: '北京市' },
- { code: '110102', name: '西城区' },
- ]);
-});
-
test('should show search result after focusing to address detail', async () => {
const wrapper = mount(AddressEdit, {
props: {