@@ -214,9 +214,89 @@ describe("Matching Service Integration Tests ", () => {
214214 expect . arrayContaining ( [ userId . id , userId2 . id ] ) ,
215215 ) ;
216216 } ) ;
217+ it ( "should only find users that are the right gender and intentions" , async ( ) => {
218+ const userId = await userFactory . persistNewTestUser ( {
219+ gender : EGender . WOMAN ,
220+ genderDesire : [ EGender . MAN ] ,
221+ intentions : [ EIntention . RELATIONSHIP , EIntention . CASUAL ] ,
222+ } ) ;
223+ const userId2 = await userFactory . persistNewTestUser ( {
224+ gender : EGender . WOMAN ,
225+ genderDesire : [ EGender . MAN ] ,
226+ intentions : [
227+ EIntention . RELATIONSHIP ,
228+ EIntention . FRIENDSHIP ,
229+ EIntention . RECONNECT_FRIENDS ,
230+ ] ,
231+ } ) ;
232+ await userFactory . persistNewTestUser ( {
233+ gender : EGender . WOMAN ,
234+ genderDesire : [ EGender . MAN ] ,
235+ intentions : [
236+ EIntention . FRIENDSHIP ,
237+ EIntention . RECONNECT_FRIENDS ,
238+ EIntention . CASUAL ,
239+ ] ,
240+ } ) ;
241+
242+ const matches = Array . from (
243+ (
244+ await matchingService . findNearbyMatches ( testingMainUser )
245+ ) . values ( ) ,
246+ ) ;
247+
248+ expect ( matches . length ) . toBe ( 2 ) ;
249+ expect ( matches . map ( ( m ) => m . id ) ) . toEqual (
250+ expect . arrayContaining ( [ userId . id , userId2 . id ] ) ,
251+ ) ;
252+ } ) ;
253+
254+ it ( "should only find users that are the right gender and intentions 2" , async ( ) => {
255+ await clearDatabase ( testingDataSource ) ;
256+
257+ const birthDay = new Date ( "1996-09-21" ) ;
258+ const testingMainUser2 = await userFactory . persistNewTestUser ( {
259+ dateMode : EDateMode . LIVE ,
260+ location : new PointBuilder ( ) . build ( 0 , 0 ) ,
261+ genderDesire : [ EGender . WOMAN ] ,
262+ gender : EGender . MAN ,
263+ intentions : [
264+ EIntention . RELATIONSHIP ,
265+ EIntention . CASUAL ,
266+ EIntention . FRIENDSHIP ,
267+ ] ,
268+ approachChoice : EApproachChoice . APPROACH ,
269+ birthDay,
270+ ageRangeString : `[${ getAge ( birthDay ) - User . defaultAgeRange } ,${ getAge ( birthDay ) + User . defaultAgeRange } ]` ,
271+ } ) ;
272+
273+ const userId2 = await userFactory . persistNewTestUser ( {
274+ gender : EGender . WOMAN ,
275+ genderDesire : [ EGender . MAN ] ,
276+ intentions : [ EIntention . RELATIONSHIP , EIntention . FRIENDSHIP ] ,
277+ } ) ;
278+
279+ const userId3 = await userFactory . persistNewTestUser ( {
280+ gender : EGender . WOMAN ,
281+ genderDesire : [ EGender . MAN ] ,
282+ intentions : [ EIntention . RELATIONSHIP , EIntention . CASUAL ] ,
283+ } ) ;
284+
285+ const matches = Array . from (
286+ (
287+ await matchingService . findNearbyMatches ( testingMainUser2 )
288+ ) . values ( ) ,
289+ ) ;
290+
291+ expect ( matches . length ) . toBe ( 2 ) ;
292+ expect ( matches . map ( ( m ) => m . id ) ) . toEqual (
293+ expect . arrayContaining ( [ userId2 . id , userId3 . id ] ) ,
294+ ) ;
295+ } ) ;
296+
217297 it ( "should only find users with a recent location update" , async ( ) => {
218298 const now = new Date ( ) ;
219- const sixHoursAgo = new Date ( now . getTime ( ) - 6 * 60 * 60 * 1000 ) ;
299+ const sixHoursAgo = new Date ( now . getTime ( ) - 24 * 60 * 60 * 1000 ) ;
220300 const twoHoursAgo = new Date ( now . getTime ( ) - 2 * 60 * 60 * 1000 ) ;
221301
222302 const baseConfiguration = {
0 commit comments