Skip to content

Commit

Permalink
fix(msw): correctly mock nested objects (#1325)
Browse files Browse the repository at this point in the history
* fix(msw): correctly mock nested objects

* Update combine.ts

---------

Co-authored-by: Alfred Jonsson <alfred.jonsson@decerno.se>
Co-authored-by: Melloware <mellowaredev@gmail.com>
  • Loading branch information
3 people committed Apr 23, 2024
1 parent 5f5dc17 commit d7fa66d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/mock/src/faker/getters/combine.ts
Expand Up @@ -103,9 +103,9 @@ export const combineSchemasMock = ({
let currentValue = resolvedValue.value;

if (itemResolvedValue?.value && separator === 'oneOf') {
currentValue = `${resolvedValue.value.slice(0, -1)},${
itemResolvedValue.value
}}`;
const splitValues = resolvedValue.value.split('},{');
const joined = splitValues.join(`,${itemResolvedValue.value}},{`);
currentValue = `${joined.slice(0, -1)},${itemResolvedValue.value}}`;
}

if (itemResolvedValue?.value && separator !== 'oneOf' && isLastElement) {
Expand Down

0 comments on commit d7fa66d

Please sign in to comment.