Add basic test

This commit is contained in:
Adria Navarro 2024-08-14 14:51:17 +02:00
parent eb2d71e980
commit f0a89764f2
1 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,6 @@
import { SearchFilters } from "@budibase/types"
import { removeInvalidFilters } from "../queryUtils"
import { FieldType, SearchFilters, Table } from "@budibase/types"
import { getQueryableFields, removeInvalidFilters } from "../queryUtils"
import { structures } from "../../../../api/routes/tests/utilities"
describe("query utils", () => {
describe("removeInvalidFilters", () => {
@ -179,4 +180,19 @@ describe("query utils", () => {
})
})
})
describe("getQueryableFields", () => {
it("allows querying by table schema fields and _id", async () => {
const table: Table = {
...structures.basicTable(),
schema: {
name: { name: "name", type: FieldType.STRING },
age: { name: "age", type: FieldType.NUMBER },
},
}
const result = await getQueryableFields(["name", "age"], table)
expect(result).toEqual(["_id", "name", "age"])
})
})
})