Skip to content

Commit

Permalink
fix(mocks): fix array enum mock generation when enum is NOT a $ref (#375
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rsanchez authored May 10, 2022
1 parent 157c1f1 commit 336612f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/getters/scalar.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { GeneratorImport } from '../../types/generator';
import { MockDefinition } from '../../types/mocks';
import { mergeDeep } from '../../utils/mergeDeep';
import { escape } from '../../utils/string';
import { isReference } from '../../utils/is';
import {
getNullable,
resolveMockOverride,
Expand Down Expand Up @@ -120,6 +121,14 @@ export const getMockScalar = async ({
});

if (enums) {
if (!isReference(item.items)) {
return {
value,
imports: resolvedImports,
name: item.name,
};
}

const enumImp = imports.find(
(imp) => name.replace('[]', '') === imp.name,
);
Expand Down

1 comment on commit 336612f

@vercel
Copy link

@vercel vercel bot commented on 336612f May 10, 2022

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.