Skip to content

Commit b33698e

Browse files
committed
add back removed tests from code review comments
1 parent 6b1009a commit b33698e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/types/middleware.preposttypes.test.ts

+45
Original file line numberDiff line numberDiff line change
@@ -832,4 +832,49 @@ schema.post(['estimatedDocumentCount', 'countDocuments', 'deleteMany', 'distinct
832832
expectNotType<Query<any, any>>(res);
833833
});
834834

835+
schema.pre(['save', 'updateOne', 'deleteOne', 'validate'], function() {
836+
expectType<Query<any, any>|HydratedDocument<IDocument>>(this);
837+
});
838+
839+
schema.post(['save', 'updateOne', 'deleteOne', 'validate'], function(res) {
840+
expectType<Query<any, any>|HydratedDocument<IDocument>>(this);
841+
expectNotType<Query<any, any>>(res);
842+
});
843+
844+
schema.pre(['save', 'updateOne', 'deleteOne', 'validate'], { document: false, query: true }, function() {
845+
expectType<Query<any, any>>(this);
846+
});
847+
848+
schema.post(['save', 'updateOne', 'deleteOne', 'validate'], { document: false, query: true }, function(res) {
849+
expectType<Query<any, any>>(this);
850+
expectNotType<Query<any, any>>(res);
851+
});
852+
853+
schema.pre(['save', 'updateOne', 'deleteOne', 'validate'], { document: true, query: false }, function() {
854+
expectType<HydratedDocument<IDocument>>(this);
855+
});
856+
857+
schema.post(['save', 'updateOne', 'deleteOne', 'validate'], { document: true, query: false }, function(res) {
858+
expectType<HydratedDocument<IDocument>>(this);
859+
expectNotType<Query<any, any>>(res);
860+
});
861+
862+
schema.pre(['save', 'updateOne', 'deleteOne', 'validate'], { document: true, query: true }, function() {
863+
expectType<Query<any, any>|HydratedDocument<IDocument>>(this);
864+
});
865+
866+
schema.post(['save', 'updateOne', 'deleteOne', 'validate'], { document: true, query: true }, function(res) {
867+
expectType<Query<any, any>|HydratedDocument<IDocument>>(this);
868+
expectNotType<Query<any, any>>(res);
869+
});
870+
871+
schema.pre(['save', 'updateOne', 'deleteOne', 'validate'], { document: false, query: false }, function() {
872+
expectType<never>(this);
873+
});
874+
875+
schema.post(['save', 'updateOne', 'deleteOne', 'validate'], { document: false, query: false }, function(res) {
876+
expectType<never>(this);
877+
expectNotType<Query<any, any>>(res);
878+
});
879+
835880
/* end of generated tests */

0 commit comments

Comments
 (0)