@@ -8,7 +8,13 @@ let mongoServer: MongoMemoryServer;
88beforeAll ( async ( ) => {
99 mongoServer = await MongoMemoryServer . create ( ) ;
1010 const mongoUri = mongoServer . getUri ( ) ;
11- await mongoose . connect ( mongoUri , { useNewUrlParser : true , useUnifiedTopology : true } ) ;
11+ await mongoose . connect (
12+ mongoUri ,
13+ {
14+ useNewUrlParser : true ,
15+ useUnifiedTopology : true ,
16+ } as any /* for tests compatibility with mongoose v5 & v6 */
17+ ) ;
1218 // mongoose.set('debug', true);
1319} ) ;
1420
@@ -31,14 +37,16 @@ describe('issue #120 - check `connection` resolver with last/before', () => {
3137
3238 it ( 'check last/before with sorting' , async ( ) => {
3339 const res1 = await resolver . resolve ( { args : { last : 2 , before : '' , sort : { _id : 1 } } } ) ;
34- expect ( res1 . edges . map ( ( { cursor, node } : any ) => ( { cursor, node : node . toString ( ) } ) ) ) . toEqual ( [
40+ expect (
41+ res1 . edges . map ( ( { cursor, node } : any ) => ( { cursor, _id : node . _id . toString ( ) } ) )
42+ ) . toEqual ( [
3543 {
3644 cursor : 'eyJfaWQiOiIxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDgifQ==' ,
37- node : '{ _id: 100000000000000000000008 } ',
45+ _id : ' 100000000000000000000008',
3846 } ,
3947 {
4048 cursor : 'eyJfaWQiOiIxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDkifQ==' ,
41- node : '{ _id: 100000000000000000000009 } ',
49+ _id : ' 100000000000000000000009',
4250 } ,
4351 ] ) ;
4452
@@ -49,29 +57,35 @@ describe('issue #120 - check `connection` resolver with last/before', () => {
4957 sort : { _id : 1 } ,
5058 } ,
5159 } ) ;
52- expect ( res2 . edges . map ( ( { cursor, node } : any ) => ( { cursor, node : node . toString ( ) } ) ) ) . toEqual ( [
60+ expect (
61+ res2 . edges . map ( ( { cursor, node } : any ) => ( { cursor, _id : node . _id . toString ( ) } ) )
62+ ) . toEqual ( [
5363 {
5464 cursor : 'eyJfaWQiOiIxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDYifQ==' ,
55- node : '{ _id: 100000000000000000000006 } ',
65+ _id : ' 100000000000000000000006',
5666 } ,
5767 {
5868 cursor : 'eyJfaWQiOiIxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDcifQ==' ,
59- node : '{ _id: 100000000000000000000007 } ',
69+ _id : ' 100000000000000000000007',
6070 } ,
6171 ] ) ;
6272 } ) ;
6373
6474 it ( 'check last/before without sorting' , async ( ) => {
6575 const res1 = await resolver . resolve ( { args : { last : 2 , before : '' } } ) ;
66- expect ( res1 . edges . map ( ( { cursor, node } : any ) => ( { cursor, node : node . toString ( ) } ) ) ) . toEqual ( [
67- { cursor : 'Nw==' , node : "{ _id: 100000000000000000000008, title: '8', __v: 0 }" } ,
68- { cursor : 'OA==' , node : "{ _id: 100000000000000000000009, title: '9', __v: 0 }" } ,
76+ expect (
77+ res1 . edges . map ( ( { cursor, node } : any ) => ( { cursor, _id : node . _id . toString ( ) } ) )
78+ ) . toEqual ( [
79+ { cursor : 'Nw==' , _id : '100000000000000000000008' } ,
80+ { cursor : 'OA==' , _id : '100000000000000000000009' } ,
6981 ] ) ;
7082
7183 const res2 = await resolver . resolve ( { args : { last : 2 , before : 'Nw==' } } ) ;
72- expect ( res2 . edges . map ( ( { cursor, node } : any ) => ( { cursor, node : node . toString ( ) } ) ) ) . toEqual ( [
73- { cursor : 'NQ==' , node : "{ _id: 100000000000000000000006, title: '6', __v: 0 }" } ,
74- { cursor : 'Ng==' , node : "{ _id: 100000000000000000000007, title: '7', __v: 0 }" } ,
84+ expect (
85+ res2 . edges . map ( ( { cursor, node } : any ) => ( { cursor, _id : node . _id . toString ( ) } ) )
86+ ) . toEqual ( [
87+ { cursor : 'NQ==' , _id : '100000000000000000000006' } ,
88+ { cursor : 'Ng==' , _id : '100000000000000000000007' } ,
7589 ] ) ;
7690 } ) ;
7791} ) ;
0 commit comments