@@ -13,9 +13,14 @@ import {
13
13
neq ,
14
14
notInArray ,
15
15
regexp ,
16
- Repository ,
16
+ Repository
17
17
} from "../../src" ;
18
- import { cleanupTestData , DomainUser , executor , setupTestTables , } from "../../test-setup" ;
18
+ import {
19
+ cleanupTestData ,
20
+ DomainUser ,
21
+ executor ,
22
+ setupTestTables
23
+ } from "../../test-setup" ;
19
24
20
25
describe ( "Repository findRows" , ( ) => {
21
26
let repository : Repository < DomainUser > ;
@@ -32,128 +37,128 @@ describe("Repository findRows", () => {
32
37
describe ( "Comparison Operators" , ( ) => {
33
38
it ( "should find rows with neq operator" , async ( ) => {
34
39
const result = await repository . find ( {
35
- where :
neq ( "email" , "[email protected] " ) ,
40
+ where :
neq ( "email" , "[email protected] " )
36
41
} ) ;
37
42
38
43
expect ( result . every ( ( user ) => user . email !== "[email protected] " ) ) . toBe (
39
- true ,
44
+ true
40
45
) ;
41
46
} ) ;
42
47
43
48
it ( "should find rows with gt operator" , async ( ) => {
44
49
const result = await repository . find ( {
45
- where : gt ( "age" , 30 ) ,
50
+ where : gt ( "age" , 30 )
46
51
} ) ;
47
52
48
53
expect ( result . every ( ( user ) => user . age ! > 30 ) ) . toBe ( true ) ;
49
54
} ) ;
50
55
51
56
it ( "should find rows with gte operator" , async ( ) => {
52
57
const result = await repository . find ( {
53
- where : gte ( "age" , 30 ) ,
58
+ where : gte ( "age" , 30 )
54
59
} ) ;
55
60
56
61
expect ( result . every ( ( user ) => user . age ! >= 30 ) ) . toBe ( true ) ;
57
62
} ) ;
58
63
59
64
it ( "should find rows with lt operator" , async ( ) => {
60
65
const result = await repository . find ( {
61
- where : lt ( "age" , 40 ) ,
66
+ where : lt ( "age" , 40 )
62
67
} ) ;
63
68
64
69
expect ( result . every ( ( user ) => user . age ! < 40 ) ) . toBe ( true ) ;
65
70
} ) ;
66
71
67
72
it ( "should find rows with lte operator" , async ( ) => {
68
73
const result = await repository . find ( {
69
- where : lte ( "age" , 40 ) ,
74
+ where : lte ( "age" , 40 )
70
75
} ) ;
71
76
72
77
expect ( result . every ( ( user ) => user . age ! <= 40 ) ) . toBe ( true ) ;
73
78
} ) ;
74
79
75
80
it ( "should find rows with like operator" , async ( ) => {
76
81
const result = await repository . find ( {
77
- where : like ( "name" , "%john%" ) ,
82
+ where : like ( "name" , "%john%" )
78
83
} ) ;
79
84
80
85
expect (
81
- result . every ( ( user ) => user . name . toLowerCase ( ) . includes ( "john" ) ) ,
86
+ result . every ( ( user ) => user . name . toLowerCase ( ) . includes ( "john" ) )
82
87
) . toBe ( true ) ;
83
88
} ) ;
84
89
85
90
it ( "should find rows with ilike operator" , async ( ) => {
86
91
const result = await repository . find ( {
87
- where : ilike ( "name" , "%JOHN%" ) ,
92
+ where : ilike ( "name" , "%JOHN%" )
88
93
} ) ;
89
94
90
95
expect (
91
- result . every ( ( user ) => user . name . toLowerCase ( ) . includes ( "john" ) ) ,
96
+ result . every ( ( user ) => user . name . toLowerCase ( ) . includes ( "john" ) )
92
97
) . toBe ( true ) ;
93
98
} ) ;
94
99
95
100
it ( "should find rows with inArray operator" , async ( ) => {
96
101
const result = await repository . find ( {
97
- where :
inArray ( "email" , [ "[email protected] " , "[email protected] " ] ) ,
102
+
98
103
} ) ;
99
104
100
105
expect (
101
106
result . every ( ( user ) =>
102
-
103
- ) ,
107
+
108
+ )
104
109
) . toBe ( true ) ;
105
110
} ) ;
106
111
107
112
it ( "should find rows with notInArray operator" , async ( ) => {
108
113
const result = await repository . find ( {
109
- where :
notInArray ( "email" , [ "[email protected] " , "[email protected] " ] ) ,
114
+ where :
notInArray ( "email" , [ "[email protected] " , "[email protected] " ] )
110
115
} ) ;
111
116
112
117
expect (
113
118
result . every (
114
119
( user ) =>
115
-
116
- ) ,
120
+
121
+ )
117
122
) . toBe ( true ) ;
118
123
} ) ;
119
124
120
125
it ( "should find rows with isNull operator" , async ( ) => {
121
126
const result = await repository . find ( {
122
- where : isNull ( "bio" ) ,
127
+ where : isNull ( "bio" )
123
128
} ) ;
124
129
125
130
expect ( result . every ( ( user ) => user . bio === null ) ) . toBe ( true ) ;
126
131
} ) ;
127
132
128
133
it ( "should find rows with isNotNull operator" , async ( ) => {
129
134
const result = await repository . find ( {
130
- where : isNotNull ( "bio" ) ,
135
+ where : isNotNull ( "bio" )
131
136
} ) ;
132
137
133
138
expect ( result . every ( ( user ) => user . bio !== null ) ) . toBe ( true ) ;
134
139
} ) ;
135
140
136
141
it ( "should find rows with between operator" , async ( ) => {
137
142
const result = await repository . find ( {
138
- where : between ( "age" , 25 , 35 ) ,
143
+ where : between ( "age" , 25 , 35 )
139
144
} ) ;
140
145
141
146
expect ( result . every ( ( user ) => user . age ! >= 25 && user . age ! <= 35 ) ) . toBe (
142
- true ,
147
+ true
143
148
) ;
144
149
} ) ;
145
150
146
151
it ( "should find rows with regexp operator" , async ( ) => {
147
152
const result = await repository . find ( {
148
- where : regexp ( "name" , "^[A-Z]" ) ,
153
+ where : regexp ( "name" , "^[A-Z]" )
149
154
} ) ;
150
155
151
156
expect ( result . every ( ( user ) => / ^ [ A - Z ] / . test ( user . name ) ) ) . toBe ( true ) ;
152
157
} ) ;
153
158
154
159
it ( "should find rows with iregexp operator" , async ( ) => {
155
160
const result = await repository . find ( {
156
- where : iregexp ( "name" , "^[a-z]" ) ,
161
+ where : iregexp ( "name" , "^[a-z]" )
157
162
} ) ;
158
163
159
164
expect ( result . every ( ( user ) => / ^ [ a - z ] / i. test ( user . name ) ) ) . toBe ( true ) ;
0 commit comments