Changeset View
Changeset View
Standalone View
Standalone View
lib/app/base-chips/special_filters/matches.subtest.js
Show All 34 Lines | describe("Matches", () => { | ||||
it("returns only positive numbers when using filter", () => | it("returns only positive numbers when using filter", () => | ||||
with_running_app(async ({ app, rest_api }) => { | with_running_app(async ({ app, rest_api }) => { | ||||
await setup(app); | await setup(app); | ||||
const result = await app.run_action( | const result = await app.run_action( | ||||
new app.Sealious.SuperContext(), | new app.Sealious.SuperContext(), | ||||
["collections", "numbers", "@positive"], | ["collections", "numbers", "@positive"], | ||||
"show" | "show" | ||||
); | ); | ||||
assert.deepEqual( | assert.deepEqual(result.items.map(resource => resource.number), [ | ||||
result.items.map(resource => resource.body.number), | 1, | ||||
[1, 2] | 2, | ||||
); | ]); | ||||
})); | })); | ||||
it("returns only positive numbers when using @positive filter", () => | it("returns only positive numbers when using @positive filter", () => | ||||
with_running_app(async ({ app, rest_api }) => { | with_running_app(async ({ app, rest_api }) => { | ||||
await setup(app); | await setup(app); | ||||
const { items } = await rest_api.get( | const { items } = await rest_api.get( | ||||
"/api/v1/collections/numbers/@positive?sort[body.number]=asc" | "/api/v1/collections/numbers/@positive?sort[number]=asc" | ||||
); | ); | ||||
assert.deepEqual(items.map(resource => resource.body.number), [ | assert.deepEqual(items.map(resource => resource.number), [1, 2]); | ||||
1, | |||||
2, | |||||
]); | |||||
})); | })); | ||||
it("returns empty array when using both @positive and @negative filters", () => | it("returns empty array when using both @positive and @negative filters", () => | ||||
with_running_app(async ({ app, rest_api }) => { | with_running_app(async ({ app, rest_api }) => { | ||||
await setup(app); | await setup(app); | ||||
const { items } = await rest_api.get( | const { items } = await rest_api.get( | ||||
"/api/v1/collections/numbers/@positive/@negative" | "/api/v1/collections/numbers/@positive/@negative" | ||||
); | ); | ||||
assert.deepEqual(items.map(resource => resource.body.number), []); | assert.deepEqual(items.map(resource => resource.number), []); | ||||
})); | })); | ||||
}); | }); |