All search tests for dates working across all datasources.

This commit is contained in:
Sam Rose 2024-04-10 17:54:45 +01:00
parent de06fe4e4c
commit ed8f0960e0
No known key found for this signature in database
1 changed files with 60 additions and 57 deletions

View File

@ -13,12 +13,12 @@ import {
jest.unmock("mssql") jest.unmock("mssql")
describe.each([ describe.each([
// ["internal", undefined], ["internal", undefined],
["internal-sqs", undefined], ["internal-sqs", undefined],
// [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)],
// [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)],
// [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)],
// [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)],
])("/api/:sourceId/search (%s)", (name, dsProvider) => { ])("/api/:sourceId/search (%s)", (name, dsProvider) => {
const isSqs = name === "internal-sqs" const isSqs = name === "internal-sqs"
const config = setup.getConfig() const config = setup.getConfig()
@ -168,7 +168,7 @@ describe.each([
) )
}) })
describe.only("dates", () => { describe("dates", () => {
beforeEach(async () => { beforeEach(async () => {
table = await config.api.table.save( table = await config.api.table.save(
tableForDatasource(datasource, { tableForDatasource(datasource, {
@ -193,61 +193,64 @@ describe.each([
} }
const dateSearchTests: DateSearchTest[] = [ const dateSearchTests: DateSearchTest[] = [
//{ query: {}, expected: rows }, { query: {}, expected: rows },
//{ {
// query: { onEmptyFilter: EmptyFilterOption.RETURN_ALL }, query: { onEmptyFilter: EmptyFilterOption.RETURN_ALL },
// expected: rows, expected: rows,
//}, },
//{ {
// query: { onEmptyFilter: EmptyFilterOption.RETURN_NONE }, query: { onEmptyFilter: EmptyFilterOption.RETURN_NONE },
// expected: [], expected: [],
//}, },
{ {
query: { equal: { dob: new Date("2020-01-01").toISOString() } }, query: { equal: { dob: new Date("2020-01-01").toISOString() } },
expected: [rows[0]], expected: [rows[0]],
}, },
// { query: { equal: { dob: new Date("2020-01-02") } }, expected: [] }, {
// { query: { equal: { dob: new Date("2020-01-02").toISOString() } },
// query: { notEqual: { dob: new Date("2020-01-01") } }, expected: [],
// expected: [rows[1]], },
// }, {
// { query: { notEqual: { dob: new Date("2020-01-01").toISOString() } },
// query: { oneOf: { dob: [new Date("2020-01-01")] } }, expected: [rows[1]],
// expected: [rows[0]], },
// }, {
// { query: { oneOf: { dob: [new Date("2020-01-01").toISOString()] } },
// query: { expected: [rows[0]],
// range: { },
// dob: { {
// low: new Date("2020-01-01").toISOString(), query: {
// high: new Date("2020-01-05").toISOString(), range: {
// }, dob: {
// }, low: new Date("2020-01-01").toISOString(),
// }, high: new Date("2020-01-05").toISOString(),
// expected: [rows[0]], },
// }, },
// { },
// query: { expected: [rows[0]],
// range: { },
// dob: { {
// low: new Date("2020-01-01").toISOString(), query: {
// high: new Date("2020-01-10").toISOString(), range: {
// }, dob: {
// }, low: new Date("2020-01-01").toISOString(),
// }, high: new Date("2020-01-10").toISOString(),
// expected: rows, },
// }, },
// { },
// query: { expected: rows,
// range: { },
// dob: { {
// low: new Date("2020-01-05").toISOString(), query: {
// high: new Date("2020-01-10").toISOString(), range: {
// }, dob: {
// }, low: new Date("2020-01-05").toISOString(),
// }, high: new Date("2020-01-10").toISOString(),
// expected: [rows[1]], },
// }, },
},
expected: [rows[1]],
},
] ]
it.each(dateSearchTests)( it.each(dateSearchTests)(