Drop the hybrid prefer gate and the gate weight from remote.js distribute

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet 5.5 committed 2026-10-04 15:27:03 +02:00
1 parent 680744278a
commit fbc0f16c4a
2 files changed
+37 -26

No files matched your search

+24 -12
View File
@@ -57,7 +57,6 @@ test("the sentence lists the areas, and says anywhere in lower case", () => {
const older = { field: "remote", values: ["remote"], mode: "any" };
const from = (...values) => ({ field: "remote_from", values, mode: "any" });
const hybrid = { field: "remote", values: ["hybrid"], mode: "prefer", weight: 0.05 };
const dk = { field: "country", values: ["DK"], mode: "any" };
const must = (...values) => ({ field: "country", values, mode: "require" });
const europe = must(...rh.EUROPE);
@@ -90,12 +89,27 @@ test("any other require gate on country is the scope with its codes as chips", (
assert.deepEqual(rest, []);
});
test("a second or weighted require gate on country stays a row", () => {
test("a second require gate on country stays a row", () => {
const second = must("NO");
const weighted = { ...must("DE"), weight: 2 };
const { where, rest } = rh.distribute([europe, second, weighted]);
const { where, rest } = rh.distribute([europe, second]);
assert.equal(where.scope.kind, "europe");
assert.deepEqual(rest, [second, weighted]);
assert.deepEqual(rest, [second]);
});
test("the titles to leave out are the exclude gate on title, and any other exclude is a row", () => {
const titles = { field: "title", values: ["account executive"], mode: "exclude" };
const level = { field: "seniority", values: ["junior"], mode: "exclude" };
const { where, rest } = rh.distribute([titles, level]);
assert.equal(where.titles, titles);
assert.deepEqual(rest, [level]);
});
test("a gate with a mode the form does not know stays a row and takes no Where line", () => {
const prefer = { field: "remote", values: ["hybrid"], mode: "prefer" };
const { where, rest } = rh.distribute([prefer]);
assert.deepEqual(where.remote, { mode: "none", values: [] });
assert.equal("hybrid" in where, false);
assert.deepEqual(rest, [prefer]);
});
test("a require gate on another field is a row and leaves the scope everywhere", () => {
@@ -106,11 +120,10 @@ test("a require gate on another field is a row and leaves the scope everywhere",
});
test("remote, three modes: the plain gate is within the scope", () => {
const scope = rh.distribute([older, hybrid]);
const scope = rh.distribute([older]);
assert.deepEqual(scope.where.remote, { mode: "scope", values: [] });
assert.equal(scope.where.hybrid, hybrid);
assert.deepEqual(scope.rest, []);
assert.deepEqual(rh.distribute([hybrid]).where.remote, { mode: "none", values: [] });
assert.deepEqual(rh.distribute([]).where.remote, { mode: "none", values: [] });
const named = rh.distribute([from("country:DK", "region:oresund")]);
assert.deepEqual(named.where.remote, { mode: "from", values: ["country:DK", "region:oresund"] });
assert.deepEqual(named.rest, []);
@@ -124,11 +137,10 @@ test("a remote_from gate wins over the plain one, which stays a row", () => {
}
});
test("a second remote_from gate, a weighted one or a must stays a row", () => {
test("a second remote_from gate or a must stays a row", () => {
const second = from("country:SE");
const weighted = { ...from("country:DE"), weight: 2 };
const required = { field: "remote_from", values: ["country:DK"], mode: "require" };
const { where, rest } = rh.distribute([from("country:DK"), second, weighted, required]);
const { where, rest } = rh.distribute([from("country:DK"), second, required]);
assert.deepEqual(where.remote, { mode: "from", values: ["country:DK"] });
assert.deepEqual(rest, [second, weighted, required]);
assert.deepEqual(rest, [second, required]);
});