@@ -164,12 +164,12 @@ describe('Query builder', () => {
164
164
test('whereIn() sets properly the builder', () => {
165
165
let post = Post.whereIn('status', ['ACTIVE', 'ARCHIVED'])
166
166
167
-
expect(post._builder.filters).toEqual({ status: 'ACTIVE,ARCHIVED' })
167
+
expect(post._builder.filters).toEqual({ status: ['ACTIVE', 'ARCHIVED'] })
168
168
169
169
post = Post.whereIn(['user', 'status'], ['active', 'inactive'])
170
170
171
171
expect(post._builder.filters).toEqual({
172
-
user: { status: 'active,inactive' }
172
+
user: { status: ['active', 'inactive'] }
173
173
})
174
174
expect(post._builder.query()).toEqual(
175
175
'?filter[user][status]=active,inactive'
@@ -181,7 +181,10 @@ describe('Query builder', () => {
181
181
).whereIn(['schedule', 'end'], ['2020-11-28', '2020-11-29'])
182
182
183
183
expect(post._builder.filters).toEqual({
184
-
schedule: { start: '2020-11-27,2020-11-28', end: '2020-11-28,2020-11-29' }
184
+
schedule: {
185
+
start: ['2020-11-27', '2020-11-28'],
186
+
end: ['2020-11-28', '2020-11-29']
187
+
}
185
188
})
186
189
expect(post._builder.query()).toEqual(
187
190
'?filter[schedule][start]=2020-11-27,2020-11-28&filter[schedule][end]=2020-11-28,2020-11-29'
@@ -241,7 +244,7 @@ describe('Query builder', () => {
241
244
test('select() for single entity', () => {
242
245
let post = Post.select('age', 'firstname')
243
246
244
-
expect(post._builder.fields.posts).toEqual('age,firstname')
247
+
expect(post._builder.fields.posts).toEqual(['age', 'firstname'])
245
248
})
246
249
247
250
test('select() for related entities', () => {
@@ -250,14 +253,19 @@ describe('Query builder', () => {
250
253
user: ['age', 'firstname']
251
254
})
252
255
253
-
expect(post._builder.fields.posts).toEqual('title,content')
254
-
expect(post._builder.fields.user).toEqual('age,firstname')
256
+
expect(post._builder.fields.posts).toEqual(['title', 'content'])
257
+
expect(post._builder.fields.user).toEqual(['age', 'firstname'])
255
258
})
256
259
257
260
test('params() sets properly the builder', () => {
258
261
let post = Post.params({ doSomething: 'yes' })
259
262
260
263
expect(post._builder.payload).toEqual({ doSomething: 'yes' })
264
+
265
+
post = Post.params({ foo: 'bar', baz: ['a', 'b'] })
266
+
267
+
expect(post._builder.payload).toEqual({ foo: 'bar', baz: ['a', 'b'] })
268
+
expect(post._builder.query()).toEqual('?foo=bar&baz=a,b')
261
269
})
262
270
263
271
test('params() throws a exception when the payload is not an object', () => {
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4