Attempting to fix tests.
This commit is contained in:
parent
f8fb08c72c
commit
a9f8a72ebd
|
@ -87,8 +87,11 @@ describe.each([
|
||||||
class SearchAssertion {
|
class SearchAssertion {
|
||||||
constructor(private readonly query: RowSearchParams) {}
|
constructor(private readonly query: RowSearchParams) {}
|
||||||
|
|
||||||
private popRow(expectedRow: any, foundRows: any[]) {
|
private popRow<T extends object>(
|
||||||
const row = foundRows.find(foundRow => _.isMatch(foundRow, expectedRow))
|
expectedRow: T,
|
||||||
|
foundRows: T[]
|
||||||
|
): NonNullable<T> {
|
||||||
|
const row = foundRows.find(row => _.isMatch(row, expectedRow))
|
||||||
if (!row) {
|
if (!row) {
|
||||||
const fields = Object.keys(expectedRow)
|
const fields = Object.keys(expectedRow)
|
||||||
// To make the error message more readable, we only include the fields
|
// To make the error message more readable, we only include the fields
|
||||||
|
@ -130,6 +133,8 @@ describe.each([
|
||||||
// passed in. The order of the rows is not important, but extra rows will
|
// passed in. The order of the rows is not important, but extra rows will
|
||||||
// cause the assertion to fail.
|
// cause the assertion to fail.
|
||||||
async toContainExactly(expectedRows: any[]) {
|
async toContainExactly(expectedRows: any[]) {
|
||||||
|
expectedRows.sort((a, b) => Object.keys(b).length - Object.keys(a).length)
|
||||||
|
|
||||||
const { rows: foundRows } = await config.api.row.search(table._id!, {
|
const { rows: foundRows } = await config.api.row.search(table._id!, {
|
||||||
...this.query,
|
...this.query,
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
|
@ -151,6 +156,8 @@ describe.each([
|
||||||
// The order of the rows is not important. Extra rows will not cause the
|
// The order of the rows is not important. Extra rows will not cause the
|
||||||
// assertion to fail.
|
// assertion to fail.
|
||||||
async toContain(expectedRows: any[]) {
|
async toContain(expectedRows: any[]) {
|
||||||
|
expectedRows.sort((a, b) => Object.keys(b).length - Object.keys(a).length)
|
||||||
|
|
||||||
const { rows: foundRows } = await config.api.row.search(table._id!, {
|
const { rows: foundRows } = await config.api.row.search(table._id!, {
|
||||||
...this.query,
|
...this.query,
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
|
@ -1055,6 +1062,7 @@ describe.each([
|
||||||
describe("notEqual", () => {
|
describe("notEqual", () => {
|
||||||
it("successfully finds a row", () =>
|
it("successfully finds a row", () =>
|
||||||
expectQuery({ notEqual: { time: T_1000 } }).toContainExactly([
|
expectQuery({ notEqual: { time: T_1000 } }).toContainExactly([
|
||||||
|
{ timeid: NULL_TIME__ID },
|
||||||
{ time: "10:45:00" },
|
{ time: "10:45:00" },
|
||||||
{ time: "12:00:00" },
|
{ time: "12:00:00" },
|
||||||
{ time: "15:30:00" },
|
{ time: "15:30:00" },
|
||||||
|
@ -1064,6 +1072,7 @@ describe.each([
|
||||||
it("return all when requesting non-existing", () =>
|
it("return all when requesting non-existing", () =>
|
||||||
expectQuery({ notEqual: { time: UNEXISTING_TIME } }).toContainExactly(
|
expectQuery({ notEqual: { time: UNEXISTING_TIME } }).toContainExactly(
|
||||||
[
|
[
|
||||||
|
{ timeid: NULL_TIME__ID },
|
||||||
{ time: "10:00:00" },
|
{ time: "10:00:00" },
|
||||||
{ time: "10:45:00" },
|
{ time: "10:45:00" },
|
||||||
{ time: "12:00:00" },
|
{ time: "12:00:00" },
|
||||||
|
@ -1668,7 +1677,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("containsAny", () => {
|
describe("containsAny", () => {
|
||||||
it("successfully finds rows", () =>
|
it.only("successfully finds rows", () =>
|
||||||
expectQuery({
|
expectQuery({
|
||||||
containsAny: { users: [user1._id, user2._id] },
|
containsAny: { users: [user1._id, user2._id] },
|
||||||
}).toContainExactly([
|
}).toContainExactly([
|
||||||
|
|
Loading…
Reference in New Issue