Files
MikrotikManager/lib/ospf-state.test.ts
T

18 lines
1015 B
TypeScript

import assert from "node:assert/strict"
import { test } from "node:test"
import { normalizeOspfState, normalizeBfdState, ospfNodeState } from "./ospf-state"
test("RouterOS states keep transitional adjacency separate from failure", () => {
assert.deepEqual(["full", "2-way", "ExStart", "exchange", "loading", "attempt", "init", "down"].map(normalizeOspfState), ["Full", "2-Way", "ExStart", "Exchange", "Loading", "Attempt", "Init", "Down"])
assert.equal(normalizeOspfState("future-state"), "Unknown")
assert.equal(normalizeBfdState(""), "Unknown")
assert.equal(normalizeBfdState(" UP "), "Up")
})
test("topology does not infer Down from missing or transitional evidence", () => {
assert.equal(ospfNodeState([]), "none")
assert.equal(ospfNodeState(["Down"]), "Down")
assert.equal(ospfNodeState(["Down", "Unknown"]), "Unknown")
assert.equal(ospfNodeState(["Exchange", "Loading"]), "Pending")
assert.equal(ospfNodeState(["2-Way", "Down"]), "2-Way")
assert.equal(ospfNodeState(["Full", "Unknown"]), "Full")
})