@tellescope/sdk 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -190,6 +190,34 @@ const threadKeyTests = async () => {
190
190
  ])
191
191
  }
192
192
 
193
+ const filterTests = async () => {
194
+ const enduser = await sdk.api.endusers.createOne({ email: 'filtertests@tellescope.com', fname: 'test' })
195
+ const otherEnduser = await sdk.api.endusers.createOne({ email: 'other@tellescope.com' })
196
+ await async_test(
197
+ `find enduser by filter`,
198
+ () => sdk.api.endusers.getSome({ filter: { email: 'filtertests@tellescope.com' }}),
199
+ { onResult: es => es.length === 1 && es[0].id === enduser.id },
200
+ )
201
+ await async_test(
202
+ `find enduser by compound filter`,
203
+ () => sdk.api.endusers.getSome({ filter: { email: 'filtertests@tellescope.com', fname: 'test' }}),
204
+ { onResult: es => es.length === 1 && es[0].id === enduser.id },
205
+ )
206
+ await async_test(
207
+ `nothing found by invalid compound filter`,
208
+ () => sdk.api.endusers.getSome({ filter: { email: 'filtertests@tellescope.com', fname: 'nottest' }}),
209
+ { onResult: es => es.length === 0 },
210
+ )
211
+ await async_test(
212
+ `nothing found for invalid filter`,
213
+ () => sdk.api.endusers.getSome({ filter: { email: 'doesnotexist@tellescope.com' }}),
214
+ { onResult: es => es.length === 0 },
215
+ )
216
+
217
+ await sdk.api.endusers.deleteOne(enduser.id)
218
+ await sdk.api.endusers.deleteOne(otherEnduser.id)
219
+ }
220
+
193
221
  const instanceForModel = <N extends ModelName, T=ClientModelForName[N], REQ=ClientModelForName_required[N]>(model: Model<T, N>, i=0) => {
194
222
  const instance = {} as Indexable
195
223
  const updates = {} as Indexable
@@ -311,7 +339,7 @@ const run_generated_tests = async <N extends ModelName>({ queries, model, name,
311
339
  await async_test(
312
340
  `update-${singularName}`,
313
341
  () => queries.updateOne(_id, updates, { replaceObjectFields: true }),
314
- passOnVoid
342
+ { onResult: u => typeof u === 'object' && u.id === _id }
315
343
  )
316
344
  }
317
345
  await async_test(
@@ -894,9 +922,10 @@ const tests: { [K in keyof ClientModelForName]: () => void } = {
894
922
 
895
923
  log_header("API")
896
924
  await setup_tests()
897
- await enduserAccessTests()
898
925
  await multi_tenant_tests() // should come right after setup tests
926
+ await filterTests()
899
927
  await threadKeyTests()
928
+ await enduserAccessTests()
900
929
 
901
930
  let n: keyof typeof schema;
902
931
  for (n in schema) {