OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
master @ 29 LINES
 
[ HISTORY ]  [ UP ]
 

import { describe, expect, it } from "vitest";
import { buildGauge, gaugeWidth } from "./Gauge";
import { len } from "../../lib/ascii";

describe("buildGauge", () => {
  it("renders the exact declared width", () => {
    for (const v of [0, 47, 100]) {
      expect(len(buildGauge(v, { cells: 10 }))).toBe(gaugeWidth(10));
      expect(len(buildGauge(v, { cells: 10, threshold: 70 }))).toBe(gaugeWidth(10,
 v >= 70 ? "CRITICAL" : "NOMINAL"));
    }
  });

  it("places the threshold marker inside the bar", () => {
    const g = buildGauge(30, { cells: 10, threshold: 70 });
    expect([...g][8]).toBe("│");
  });

  it("flips the status word at the threshold", () => {
    expect(buildGauge(47, { threshold: 70 })).toContain("NOMINAL");
    expect(buildGauge(85, { threshold: 70 })).toContain("CRITICAL");
  });

  it("omits marker and status without a threshold", () => {
    const g = buildGauge(47, { cells: 10 });
    expect(g).not.toContain("│");
    expect(g.trimEnd().endsWith("%")).toBe(true);
  });
});

import { describe, expect, it } from "vitest
";
import { buildGauge, gaugeWidth } from "./Ga
uge";
import { len } from "../../lib/ascii";

describe("buildGauge", () => {
  it("renders the exact declared width", () 
=> {
    for (const v of [0, 47, 100]) {
      expect(len(buildGauge(v, { cells: 10 }
))).toBe(gaugeWidth(10));
      expect(len(buildGauge(v, { cells: 10, 
threshold: 70 }))).toBe(gaugeWidth(10, v >= 
70 ? "CRITICAL" : "NOMINAL"));
    }
  });

  it("places the threshold marker inside the
 bar", () => {
    const g = buildGauge(30, { cells: 10, th
reshold: 70 });
    expect([...g][8]).toBe("│");
  });

  it("flips the status word at the threshold
", () => {
    expect(buildGauge(47, { threshold: 70 })
).toContain("NOMINAL");
    expect(buildGauge(85, { threshold: 70 })
).toContain("CRITICAL");
  });

  it("omits marker and status without a thre
shold", () => {
    const g = buildGauge(47, { cells: 10 });
    expect(g).not.toContain("│");
    expect(g.trimEnd().endsWith("%")).toBe(t
rue);
  });
});
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET