Skip to content

Commit

Permalink
test(core): update tests for copy/paste
Browse files Browse the repository at this point in the history
Client must be mocked for ref. type checks
  • Loading branch information
skogsmaskin committed Jul 1, 2024
1 parent f820bfe commit 0716a9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export function createMockClient(mockData: Record<string, FIXME> = {}): ClientWi
return mockData[ref] as R
}
}
if (query.includes('*[_id == $id][0]') && isNonNullObject(params) && 'id' in params) {
const id = params.id as string
if (typeof id === 'string' && id in mockData) {
return mockData[id] as R
}
}
throw new Error('Unexpected query or params in mock client')
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ describe('transferValue', () => {
sourceValue,
targetRootSchemaType: schema.get('editor')!,
targetPath: ['relatedEditor'],
options: {
validateReferences: true,
client: createMockClient({
yyy: {_type: 'author', _id: 'yyy'},
}),
},
})
expect(transferValueResult?.errors.length).toEqual(1)
expect(transferValueResult?.targetValue).toEqual(undefined)
Expand Down

0 comments on commit 0716a9c

Please sign in to comment.