Skip to content

Commit

Permalink
test(validation): drop test asserting eager execution of nested valid…
Browse files Browse the repository at this point in the history
…ation checks
  • Loading branch information
bjoerge committed Sep 26, 2022
1 parent dcaad24 commit 9044965
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions packages/@sanity/validation/src/validateDocument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,84 +698,4 @@ describe('validateItem', () => {
},
])
})

it('runs all nested validation checks concurrently', async () => {
type Resolver = (value: true) => void
const resolvers = new Set<Resolver>()
const customValidationFn = () => new Promise<true>((resolve) => resolvers.add(resolve))

const schema: Schema = createSchema({
types: [
{
name: 'root',
type: 'object',
fields: [
{
name: 'level1Object',
type: 'object',
validation: (rule: Rule) => [
rule.custom(customValidationFn),
rule.fields({
level2String: (r) => r.custom(customValidationFn),
}),
],
fields: [
{
name: 'level2String',
type: 'string',
validation: (rule: Rule) => rule.custom(customValidationFn),
},
],
},
{
name: 'level1Array',
type: 'array',
validation: (rule: Rule) => rule.custom(customValidationFn),
of: [
{
type: 'object',
fields: [
{
name: 'level2Number',
type: 'number',
validation: (rule: Rule) => rule.custom(customValidationFn),
},
],
},
],
},
],
validation: (rule: Rule) => rule.custom(customValidationFn),
},
],
})

const value = {
level1Object: {level3String: 'a string'},
level1Array: [{level2Number: 5}],
}

const resultPromise = validateItem({
client,
getClient,
schema,
value,
document: undefined,
parent: undefined,
path: undefined,
type: schema.get('root'),
getDocumentExists: undefined,
})

// after `validateItem(...)` has been initiated, all of the custom
// validation calls should have fired so the resolver size should equal the
// amount of total fields
expect(resolvers.size).toBe(6)

for (const resolver of resolvers) {
resolver(true)
}

await resultPromise
})
})

0 comments on commit 9044965

Please sign in to comment.