Skip to content

Commit

Permalink
test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 5, 2024
1 parent 9316aae commit 3773c06
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/types/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ function gh14696() {
const x: ValidateOpts<unknown, User> = {
validator(v: any) {
expectAssignable<User | Query<unknown, User>>(this);
return !v || this instanceof Query || (this.name === 'super admin');
return !v || this instanceof Query || this.name === 'super admin';
}
};

Expand All @@ -1565,10 +1565,7 @@ function gh14696() {
if (!v) {
return true;
}
if (this instanceof Query) {
return true;
}
return this.name === 'super admin' || this.isSuperAdmin();
return this.get('name') === 'super admin' || (!(this instanceof Query) && this.isSuperAdmin());
}
}
},
Expand All @@ -1578,6 +1575,10 @@ function gh14696() {
validate: {
async validator(v: any) {
expectAssignable<User | Query<unknown, User>>(this);
if (this instanceof Query) {
const doc = await this.clone().findOne().orFail();
return doc.isSuperAdmin();
}
return !v || this.get('name') === 'super admin';
}
}
Expand Down

0 comments on commit 3773c06

Please sign in to comment.