mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
test(environment): consolidate generated task coverage (#11981)
This commit is contained in:
1 parent
222122fb79
commit
ddb711270d
2 files changed
+34
-40
No files matched your search
@@ -17,6 +17,30 @@ const objectOf = (body: JsonValue | undefined) => {
|
||||
describe("served creates that count and make values", () => {
|
||||
it("numbers created tasks on from the recorded counter and makes each one's subscription", () => {
|
||||
const tasks = servedFrom(COUNTED_TASK_ROWS);
|
||||
const plan = tasks.state.writes.get("post_projects_tasks_by_id");
|
||||
expect(plan).toMatchObject({
|
||||
served: true,
|
||||
checked_record_ordinals: [4, 7],
|
||||
});
|
||||
expect(plan?.rules.find(({ field }) => field === "index")).toEqual({
|
||||
field: "index",
|
||||
rule: "sequence",
|
||||
scope: "collection",
|
||||
start: 15,
|
||||
});
|
||||
expect(plan?.rules.find(({ field }) => field === "identifier")).toEqual({
|
||||
field: "identifier",
|
||||
rule: "template",
|
||||
from: "index",
|
||||
});
|
||||
expect(
|
||||
plan?.rules.find(({ field }) => field === "subscription"),
|
||||
).toMatchObject({
|
||||
rule: "made-object",
|
||||
clocks: ["created"],
|
||||
own: ["entity_id"],
|
||||
counts: [{ member: "id", start: 21 }],
|
||||
});
|
||||
const first = objectOf(
|
||||
tasks.answer("post_projects_tasks_by_id", {
|
||||
id: "5",
|
||||
@@ -51,8 +75,14 @@ describe("served creates that count and make values", () => {
|
||||
expect(read["subscription"]).toMatchObject({ entity_id: 99 });
|
||||
});
|
||||
|
||||
it("answers a bulk create in the envelope it was sent in", () => {
|
||||
it("answers bulk creates in their envelope and honors the requested project", () => {
|
||||
const tasks = servedFrom(BULK_TASK_ROWS);
|
||||
expect(
|
||||
tasks.state.writes.get("post_projects_tasks_bulk_by_id"),
|
||||
).toMatchObject({
|
||||
served: true,
|
||||
body: { envelope: "tasks" },
|
||||
});
|
||||
const body = objectOf(
|
||||
tasks.answer("post_projects_tasks_bulk_by_id", {
|
||||
id: "5",
|
||||
@@ -62,16 +92,12 @@ describe("served creates that count and make values", () => {
|
||||
expect(body["tasks"]).toMatchObject([
|
||||
{ title: "Restock the fog-horn spares", index: 15, identifier: "#15" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("creates into another project when the task stores its project and lands in one collection", () => {
|
||||
const tasks = servedFrom(BULK_TASK_ROWS);
|
||||
const body = objectOf(
|
||||
const other = objectOf(
|
||||
tasks.answer("post_projects_tasks_bulk_by_id", {
|
||||
id: "7",
|
||||
body: { tasks: [{ title: "Paint the gallery rail" }] },
|
||||
}).body,
|
||||
);
|
||||
expect(body["tasks"]).toMatchObject([{ project_id: 7 }]);
|
||||
expect(other["tasks"]).toMatchObject([{ project_id: 7 }]);
|
||||
});
|
||||
});
|
||||
@@ -5,8 +5,6 @@ import {
|
||||
type TimedCaptureRow,
|
||||
} from "../../../tests/fixtures/analysisView.js";
|
||||
import {
|
||||
BULK_TASK_ROWS,
|
||||
COUNTED_TASK_ROWS,
|
||||
MISLINKED_TASK_ROWS,
|
||||
ONE_TASK_ROWS,
|
||||
RESPELLED_TASK_ROWS,
|
||||
@@ -52,31 +50,6 @@ describe("values an application counts and makes with each created entity", () =
|
||||
expect(plan).toMatchObject({ served: false });
|
||||
expect(ruleFor(plan, "index")).toBeUndefined();
|
||||
});
|
||||
it("learns a counter from where the first create stood, a template around it and the object made with each task", () => {
|
||||
const plan = createOf(COUNTED_TASK_ROWS);
|
||||
expect(plan).toMatchObject({
|
||||
served: true,
|
||||
checked_record_ordinals: [4, 7],
|
||||
});
|
||||
expect(ruleFor(plan, "index")).toEqual({
|
||||
field: "index",
|
||||
rule: "sequence",
|
||||
scope: "collection",
|
||||
start: 15,
|
||||
});
|
||||
expect(ruleFor(plan, "identifier")).toEqual({
|
||||
field: "identifier",
|
||||
rule: "template",
|
||||
from: "index",
|
||||
});
|
||||
expect(ruleFor(plan, "subscription")).toMatchObject({
|
||||
rule: "made-object",
|
||||
clocks: ["created"],
|
||||
own: ["entity_id"],
|
||||
counts: [{ member: "id", start: 21 }],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a value one create alone shows past what the type held", () => {
|
||||
const plan = createOf(ONE_TASK_ROWS);
|
||||
expect(ruleFor(plan, "index")).toBeUndefined();
|
||||
@@ -86,12 +59,7 @@ describe("values an application counts and makes with each created entity", () =
|
||||
});
|
||||
});
|
||||
|
||||
it("links a create whose answer wraps the entity in a one-element array member", () => {
|
||||
expect(createOf(BULK_TASK_ROWS)).toMatchObject({
|
||||
tool: "post_projects_tasks_bulk_by_id",
|
||||
served: true,
|
||||
body: { envelope: "tasks" },
|
||||
});
|
||||
it("takes an identity from a sole wrapped entity and refuses an ambiguous array", () => {
|
||||
expect(respondedIds({ tasks: [{ id: 14 }] })).toEqual(["14"]);
|
||||
expect(respondedIds({ tasks: [{ id: 14 }, { id: 15 }] })).toEqual([]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user