Fix view test
This commit is contained in:
parent
b63b61655b
commit
1a7a1cdd1b
|
@ -1123,7 +1123,7 @@ describe.each([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
it.only("returns table rows from view", async () => {
|
it("returns empty rows from view when no schema is passed", async () => {
|
||||||
const table = await config.createTable(await userTable())
|
const table = await config.createTable(await userTable())
|
||||||
const rows = []
|
const rows = []
|
||||||
for (let i = 0; i < 10; i++) {
|
for (let i = 0; i < 10; i++) {
|
||||||
|
@ -1135,7 +1135,17 @@ describe.each([
|
||||||
|
|
||||||
expect(response.body.rows).toHaveLength(10)
|
expect(response.body.rows).toHaveLength(10)
|
||||||
expect(response.body).toEqual({
|
expect(response.body).toEqual({
|
||||||
rows: expect.arrayContaining(rows.map(expect.objectContaining)),
|
rows: expect.arrayContaining(
|
||||||
|
rows.map(r => ({
|
||||||
|
_viewId: createViewResponse.id,
|
||||||
|
tableId: table._id,
|
||||||
|
_id: r._id,
|
||||||
|
_rev: r._rev,
|
||||||
|
...defaultRowFields,
|
||||||
|
}))
|
||||||
|
),
|
||||||
|
hasNextPage: false,
|
||||||
|
bookmark: null,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ function pickApi(tableId: any) {
|
||||||
export async function search(options: SearchParams): Promise<{
|
export async function search(options: SearchParams): Promise<{
|
||||||
rows: any[]
|
rows: any[]
|
||||||
hasNextPage?: boolean
|
hasNextPage?: boolean
|
||||||
bookmark?: number | null
|
bookmark?: number | string | null
|
||||||
}> {
|
}> {
|
||||||
return pickApi(options.tableId).search(options)
|
return pickApi(options.tableId).search(options)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,11 @@ export async function search(options: SearchParams) {
|
||||||
if (paginate) {
|
if (paginate) {
|
||||||
response = await paginatedSearch(query, params)
|
response = await paginatedSearch(query, params)
|
||||||
} else {
|
} else {
|
||||||
response = await fullSearch(query, params)
|
response = {
|
||||||
|
...(await fullSearch(query, params)),
|
||||||
|
hasNextPage: false,
|
||||||
|
bookmark: null,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enrich search results with relationships
|
// Enrich search results with relationships
|
||||||
|
|
Loading…
Reference in New Issue