Fix datasource.spec.ts tests.

This commit is contained in:
Sam Rose 2024-08-06 14:29:31 +01:00
parent 00970d5db3
commit 3b603bdd35
No known key found for this signature in database
1 changed files with 18 additions and 2 deletions

View File

@ -444,6 +444,10 @@ describe("/datasources", () => {
describe("info", () => { describe("info", () => {
it("should fetch information about a datasource with a single table", async () => { it("should fetch information about a datasource with a single table", async () => {
const existingTableNames = (
await config.api.datasource.info(datasource)
).tableNames
const tableName = generator.guid() const tableName = generator.guid()
await client.schema.createTable(tableName, table => { await client.schema.createTable(tableName, table => {
table.increments("id").primary() table.increments("id").primary()
@ -451,10 +455,17 @@ describe("/datasources", () => {
}) })
const info = await config.api.datasource.info(datasource) const info = await config.api.datasource.info(datasource)
expect(info.tableNames).toEqual([tableName]) expect(info.tableNames).toEqual(
expect.arrayContaining([tableName, ...existingTableNames])
)
expect(info.tableNames).toHaveLength(existingTableNames.length + 1)
}) })
it("should fetch information about a datasource with multiple tables", async () => { it("should fetch information about a datasource with multiple tables", async () => {
const existingTableNames = (
await config.api.datasource.info(datasource)
).tableNames
const tableNames = [ const tableNames = [
generator.guid(), generator.guid(),
generator.guid(), generator.guid(),
@ -469,7 +480,12 @@ describe("/datasources", () => {
} }
const info = await config.api.datasource.info(datasource) const info = await config.api.datasource.info(datasource)
expect(info.tableNames).toEqual(expect.arrayContaining(tableNames)) expect(info.tableNames).toEqual(
expect.arrayContaining([...tableNames, ...existingTableNames])
)
expect(info.tableNames).toHaveLength(
existingTableNames.length + tableNames.length
)
}) })
}) })
}) })