Skip to content

Commit aaa4fa8

Browse files
committed
fix test
1 parent b0fc8ea commit aaa4fa8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/utils/get-form-value.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import mapValues from './map-values';
2+
import toArray from './to-array';
23

34
export default function getFormValue(form) {
45
if (form && !form.$form) {
@@ -15,7 +16,7 @@ export default function getFormValue(form) {
1516

1617
delete result.$form;
1718

18-
const isArray = Array.isArray(form.$form.value);
19+
const isArray = form && form.$form && Array.isArray(form.$form.value);
1920

20-
return isArray ? Object.values(result) : result;
21+
return isArray ? toArray(result) : result;
2122
}

src/utils/to-array.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default function toArray(object) {
2+
const result = [];
3+
Object.keys(object).forEach(key => {
4+
if (object.hasOwnProperty(key)) {
5+
result.push(object[key]);
6+
}
7+
});
8+
return result;
9+
}

0 commit comments

Comments
 (0)