Skip to content

Commit

Permalink
fix(mock): escape correctly enums
Browse files Browse the repository at this point in the history
  • Loading branch information
anymaniax committed Oct 1, 2021
1 parent 215d0c3 commit e19ec91
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/getters/scalar.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ContextSpecs, MockOptions } from '../../types';
import { GeneratorImport } from '../../types/generator';
import { MockDefinition } from '../../types/mocks';
import { mergeDeep } from '../../utils/mergeDeep';
import { escape } from '../../utils/string';
import {
getNullable,
resolveMockOverride,
Expand Down Expand Up @@ -136,7 +137,8 @@ export const getMockScalar = async ({
let imports: GeneratorImport[] = [];

if (item.enum) {
let enumValue = "['" + item.enum.join("','") + "']";
let enumValue =
"['" + item.enum.map((e) => escape(e)).join("','") + "']";

if (item.isRef) {
enumValue = `Object.values(${item.name})`;
Expand Down

1 comment on commit e19ec91

@vercel
Copy link

@vercel vercel bot commented on e19ec91 Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.