swarm-ui: turn an archetype agent into a custom one from its detail
This commit is contained in:
parent
0737798d78
commit
83bb47d134
1 changed files with 118 additions and 5 deletions
|
|
@ -3,7 +3,10 @@
|
|||
// imported as it is.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { showsLoginNeeded } from "../src/agent/AgentTypes.ts";
|
||||
import {
|
||||
canTurnIntoCustom,
|
||||
showsLoginNeeded,
|
||||
} from "../src/agent/AgentTypes.ts";
|
||||
|
||||
test("an agent that says it needs a login gets the badge", () => {
|
||||
assert.equal(showsLoginNeeded({ needs_login: true }), true);
|
||||
|
|
@ -17,3 +20,25 @@ test("an agent that has not said gets none", () => {
|
|||
assert.equal(showsLoginNeeded({ needs_login: null }), false);
|
||||
assert.equal(showsLoginNeeded({}), false);
|
||||
});
|
||||
|
||||
test("turn into custom is offered to a placed archetype agent only", () => {
|
||||
const archetype = { source: "hyperhive", name: "reviewer" };
|
||||
assert.equal(
|
||||
canTurnIntoCustom({ archetype, hive: "alpha", wanted: "up" }),
|
||||
true,
|
||||
);
|
||||
// A custom agent has no archetype to turn from.
|
||||
assert.equal(
|
||||
canTurnIntoCustom({ archetype: null, hive: "alpha", wanted: "up" }),
|
||||
false,
|
||||
);
|
||||
// The controller places the conversion on a hive, so one is needed.
|
||||
assert.equal(
|
||||
canTurnIntoCustom({ archetype, hive: null, wanted: "up" }),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
canTurnIntoCustom({ archetype, hive: "alpha", wanted: "destroyed" }),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue