1
0
Fork 0
mirror of synced 2024-09-20 19:33:10 +12:00

Add tests

This commit is contained in:
Adria Navarro 2024-07-31 14:01:38 +02:00
parent 95b18076d4
commit 543d0e1ce6

View file

@ -1640,23 +1640,38 @@ describe.each([
table = await config.api.table.save(defaultTable()) table = await config.api.table.save(defaultTable())
}) })
it("should allow exporting all columns", async () => { isInternal &&
const existing = await config.api.row.save(table._id!, {}) it("should not export internal couchdb fields", async () => {
const res = await config.api.row.exportRows(table._id!, { const existing = await config.api.row.save(table._id!, {
rows: [existing._id!], name: generator.guid(),
}) description: generator.paragraph(),
const results = JSON.parse(res) })
expect(results.length).toEqual(1) const res = await config.api.row.exportRows(table._id!, {
const row = results[0] rows: [existing._id!],
})
const results = JSON.parse(res)
expect(results.length).toEqual(1)
const row = results[0]
// Ensure all original columns were exported expect(Object.keys(row)).toEqual(["_id", "name", "description"])
expect(Object.keys(row).length).toBeGreaterThanOrEqual( })
Object.keys(existing).length
) !isInternal &&
Object.keys(existing).forEach(key => { it("should allow exporting all columns", async () => {
expect(row[key]).toEqual(existing[key]) const existing = await config.api.row.save(table._id!, {})
const res = await config.api.row.exportRows(table._id!, {
rows: [existing._id!],
})
const results = JSON.parse(res)
expect(results.length).toEqual(1)
const row = results[0]
// Ensure all original columns were exported
expect(Object.keys(row).length).toBe(Object.keys(existing).length)
Object.keys(existing).forEach(key => {
expect(row[key]).toEqual(existing[key])
})
}) })
})
it("should allow exporting only certain columns", async () => { it("should allow exporting only certain columns", async () => {
const existing = await config.api.row.save(table._id!, {}) const existing = await config.api.row.save(table._id!, {})