@@ -86,6 +86,36 @@ describe('Select', () => {
86
86
} )
87
87
} )
88
88
89
+ it ( 'should select only select' , async ( ) => {
90
+ const res = await payload . findByID ( {
91
+ collection : 'posts' ,
92
+ id : postId ,
93
+ select : {
94
+ select : true ,
95
+ } ,
96
+ } )
97
+
98
+ expect ( res ) . toStrictEqual ( {
99
+ id : postId ,
100
+ select : post . select ,
101
+ } )
102
+ } )
103
+
104
+ it ( 'should select only hasMany select' , async ( ) => {
105
+ const res = await payload . findByID ( {
106
+ collection : 'posts' ,
107
+ id : postId ,
108
+ select : {
109
+ selectMany : true ,
110
+ } ,
111
+ } )
112
+
113
+ expect ( res ) . toStrictEqual ( {
114
+ id : postId ,
115
+ selectMany : post . selectMany ,
116
+ } )
117
+ } )
118
+
89
119
it ( 'should select number and text' , async ( ) => {
90
120
const res = await payload . findByID ( {
91
121
collection : 'posts' ,
@@ -367,6 +397,38 @@ describe('Select', () => {
367
397
expect ( res ) . toStrictEqual ( expected )
368
398
} )
369
399
400
+ it ( 'should exclude select' , async ( ) => {
401
+ const res = await payload . findByID ( {
402
+ collection : 'posts' ,
403
+ id : postId ,
404
+ select : {
405
+ select : false ,
406
+ } ,
407
+ } )
408
+
409
+ const expected = { ...post }
410
+
411
+ delete expected [ 'select' ]
412
+
413
+ expect ( res ) . toStrictEqual ( expected )
414
+ } )
415
+
416
+ it ( 'should exclude hasMany select' , async ( ) => {
417
+ const res = await payload . findByID ( {
418
+ collection : 'posts' ,
419
+ id : postId ,
420
+ select : {
421
+ selectMany : false ,
422
+ } ,
423
+ } )
424
+
425
+ const expected = { ...post }
426
+
427
+ delete expected [ 'selectMany' ]
428
+
429
+ expect ( res ) . toStrictEqual ( expected )
430
+ } )
431
+
370
432
it ( 'should exclude number and text' , async ( ) => {
371
433
const res = await payload . findByID ( {
372
434
collection : 'posts' ,
@@ -573,6 +635,36 @@ describe('Select', () => {
573
635
} )
574
636
} )
575
637
638
+ it ( 'should select only select' , async ( ) => {
639
+ const res = await payload . findByID ( {
640
+ collection : 'localized-posts' ,
641
+ id : postId ,
642
+ select : {
643
+ select : true ,
644
+ } ,
645
+ } )
646
+
647
+ expect ( res ) . toStrictEqual ( {
648
+ id : postId ,
649
+ select : post . select ,
650
+ } )
651
+ } )
652
+
653
+ it ( 'should select only hasMany select' , async ( ) => {
654
+ const res = await payload . findByID ( {
655
+ collection : 'localized-posts' ,
656
+ id : postId ,
657
+ select : {
658
+ selectMany : true ,
659
+ } ,
660
+ } )
661
+
662
+ expect ( res ) . toStrictEqual ( {
663
+ id : postId ,
664
+ selectMany : post . selectMany ,
665
+ } )
666
+ } )
667
+
576
668
it ( 'should select number and text' , async ( ) => {
577
669
const res = await payload . findByID ( {
578
670
collection : 'localized-posts' ,
@@ -877,6 +969,38 @@ describe('Select', () => {
877
969
expect ( res ) . toStrictEqual ( expected )
878
970
} )
879
971
972
+ it ( 'should exclude select' , async ( ) => {
973
+ const res = await payload . findByID ( {
974
+ collection : 'localized-posts' ,
975
+ id : postId ,
976
+ select : {
977
+ select : false ,
978
+ } ,
979
+ } )
980
+
981
+ const expected = { ...post }
982
+
983
+ delete expected [ 'select' ]
984
+
985
+ expect ( res ) . toStrictEqual ( expected )
986
+ } )
987
+
988
+ it ( 'should exclude hasMany select' , async ( ) => {
989
+ const res = await payload . findByID ( {
990
+ collection : 'localized-posts' ,
991
+ id : postId ,
992
+ select : {
993
+ selectMany : false ,
994
+ } ,
995
+ } )
996
+
997
+ const expected = { ...post }
998
+
999
+ delete expected [ 'selectMany' ]
1000
+
1001
+ expect ( res ) . toStrictEqual ( expected )
1002
+ } )
1003
+
880
1004
it ( 'should exclude number and text' , async ( ) => {
881
1005
const res = await payload . findByID ( {
882
1006
collection : 'localized-posts' ,
@@ -1963,6 +2087,8 @@ function createPost() {
1963
2087
data : {
1964
2088
number : 1 ,
1965
2089
text : 'text' ,
2090
+ select : 'a' ,
2091
+ selectMany : [ 'a' ] ,
1966
2092
group : {
1967
2093
number : 1 ,
1968
2094
text : 'text' ,
@@ -2002,6 +2128,8 @@ function createLocalizedPost() {
2002
2128
data : {
2003
2129
number : 1 ,
2004
2130
text : 'text' ,
2131
+ select : 'a' ,
2132
+ selectMany : [ 'a' ] ,
2005
2133
group : {
2006
2134
number : 1 ,
2007
2135
text : 'text' ,
0 commit comments