Skip to content

Commit c41635b

Browse files
authoredJan 22, 2024
fix(mock): null is excluded instead of being converted to an empty string '' (#1166)
1 parent 461e813 commit c41635b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎packages/mock/src/faker/getters/scalar.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,12 @@ export const getMockScalar = ({
211211
if (item.enum) {
212212
// By default the value isn't a reference, so we don't have the object explicitly defined.
213213
// So we have to create an array with the enum values and force them to be a const.
214-
let enumValue =
215-
"['" + item.enum.map((e) => escape(e)).join("','") + "'] as const";
214+
const joindEnumValues = item.enum
215+
.filter(Boolean)
216+
.map((e) => escape(e))
217+
.join("','");
218+
219+
let enumValue = `['${joindEnumValues}'] as const`;
216220

217221
// But if the value is a reference, we can use the object directly via the imports and using Object.values.
218222
if (item.isRef) {

0 commit comments

Comments
 (0)
Please sign in to comment.