Skip to content

Commit

Permalink
fix(mock): null is excluded instead of being converted to an empty …
Browse files Browse the repository at this point in the history
…string `''` (#1166)
  • Loading branch information
soartec-lab authored Jan 22, 2024
1 parent 461e813 commit c41635b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/mock/src/faker/getters/scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,12 @@ export const getMockScalar = ({
if (item.enum) {
// By default the value isn't a reference, so we don't have the object explicitly defined.
// So we have to create an array with the enum values and force them to be a const.
let enumValue =
"['" + item.enum.map((e) => escape(e)).join("','") + "'] as const";
const joindEnumValues = item.enum
.filter(Boolean)
.map((e) => escape(e))
.join("','");

let enumValue = `['${joindEnumValues}'] as const`;

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

0 comments on commit c41635b

Please sign in to comment.