@@ -831,6 +831,15 @@ describe("check not overridden static methods", function () {
831831 should . not . exist ( err ) ;
832832 }
833833 } ) ;
834+
835+ it ( "distinct() -> should return 3 documents" , async function ( ) {
836+ try {
837+ const doc = await TestModel . distinct ( 'name' ) ;
838+ doc . should . have . members ( [ 'Obi-Wan Kenobi' , 'Darth Vader' , 'Luke Skywalker' ] ) ;
839+ } catch ( err ) {
840+ should . not . exist ( err ) ;
841+ }
842+ } ) ;
834843} ) ;
835844
836845describe ( "check overridden static methods: { overrideMethods: 'all' }" , function ( ) {
@@ -1166,6 +1175,33 @@ describe("check overridden static methods: { overrideMethods: 'all' }", function
11661175 should . not . exist ( err ) ;
11671176 }
11681177 } ) ;
1178+
1179+ it ( "distinct() -> should return 1 documents" , async function ( ) {
1180+ try {
1181+ const doc = await TestModel . distinct ( 'name' ) ;
1182+ doc . should . have . members ( [ 'Darth Vader' ] ) ;
1183+ } catch ( err ) {
1184+ should . not . exist ( err ) ;
1185+ }
1186+ } ) ;
1187+
1188+ it ( "distinctDeleted() -> should return 2 documents" , async function ( ) {
1189+ try {
1190+ const doc = await TestModel . distinctDeleted ( 'name' ) ;
1191+ doc . should . have . members ( [ 'Obi-Wan Kenobi' , 'Luke Skywalker' ] ) ;
1192+ } catch ( err ) {
1193+ should . not . exist ( err ) ;
1194+ }
1195+ } ) ;
1196+
1197+ it ( "distinctWithDeleted() -> should return 3 documents" , async function ( ) {
1198+ try {
1199+ const doc = await TestModel . distinctWithDeleted ( 'name' ) ;
1200+ doc . should . have . members ( [ 'Obi-Wan Kenobi' , 'Darth Vader' , 'Luke Skywalker' ] ) ;
1201+ } catch ( err ) {
1202+ should . not . exist ( err ) ;
1203+ }
1204+ } ) ;
11691205} ) ;
11701206
11711207describe ( "check the existence of override static methods: { overrideMethods: true }" , function ( ) {
@@ -1270,9 +1306,9 @@ describe("check the existence of override static methods: { overrideMethods: tru
12701306 } ) ;
12711307} ) ;
12721308
1273- describe ( "check the existence of override static methods: { overrideMethods: ['testError', 'count', 'countDocuments', 'find', 'findOne', 'findOneAndUpdate', 'update', 'updateOne', 'updateMany'] }" , function ( ) {
1309+ describe ( "check the existence of override static methods: { overrideMethods: ['testError', 'count', 'countDocuments', 'find', 'findOne', 'findOneAndUpdate', 'update', 'updateOne', 'updateMany', 'distinct' ] }" , function ( ) {
12741310 var TestSchema = new Schema ( { name : String } , { collection : 'mongoose_delete_test' } ) ;
1275- TestSchema . plugin ( mongoose_delete , { overrideMethods : [ 'testError' , 'count' , 'countDocuments' , 'find' , 'findOne' , 'findOneAndUpdate' , 'update' , 'updateOne' , 'updateMany' ] } ) ;
1311+ TestSchema . plugin ( mongoose_delete , { overrideMethods : [ 'testError' , 'count' , 'countDocuments' , 'find' , 'findOne' , 'findOneAndUpdate' , 'update' , 'updateOne' , 'updateMany' , 'distinct' ] } ) ;
12761312 var TestModel = mongoose . model ( 'Test7' , TestSchema ) ;
12771313
12781314 it ( "testError() -> method should not exist" , function ( ) {
@@ -1374,6 +1410,18 @@ describe("check the existence of override static methods: { overrideMethods: ['t
13741410 it ( "updateManyWithDeleted() -> method should exist" , function ( ) {
13751411 expect ( TestModel . updateManyWithDeleted ) . to . exist ;
13761412 } ) ;
1413+
1414+ it ( "distinct() => method should exist" , function ( ) {
1415+ expect ( TestModel . distinct ) . to . exist ;
1416+ } ) ;
1417+
1418+ it ( "distinctDeleted() => method should exist" , function ( ) {
1419+ expect ( TestModel . distinctDeleted ) . to . exist ;
1420+ } ) ;
1421+
1422+ it ( "distinctWithDeleted() => method should exist" , function ( ) {
1423+ expect ( TestModel . distinctWithDeleted ) . to . exist ;
1424+ } ) ;
13771425} ) ;
13781426
13791427describe ( "check the existence of override static methods: { overrideMethods: ['count', 'countDocuments', 'find'] }" , function ( ) {
0 commit comments