diff --git a/src/__tests__/filters-formatNodeProp.spec.ts b/src/__tests__/filters-formatNodeProp.spec.ts deleted file mode 100644 index 9618ff13..00000000 --- a/src/__tests__/filters-formatNodeProp.spec.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { describe, it, expect } from "vitest" -import { formatNodeProp } from "@/filters" -import { NodeProp } from "@/enums" - - -describe("formatNodeProp", () => { - describe("duration", () => { - it("formats duration", () => { - expect(formatNodeProp(NodeProp.ACTUAL_TOTAL_TIME, 1234.56)).toBe("1s 235ms"); - }) - it("returns N/A for undefined", () => { - expect(formatNodeProp(NodeProp.ACTUAL_TOTAL_TIME, undefined)).toBe("-"); - }) - }) - - describe("cost", () => { - it("formats cost", () => { - expect(formatNodeProp(NodeProp.TOTAL_COST, 1234.56)).toBe("1,234.56"); - }) - it("formats cost with fraction digits", () => { - expect(formatNodeProp(NodeProp.TOTAL_COST, 1234)).toBe("1,234.00"); - }) - it("returns N/A for undefined", () => { - expect(formatNodeProp(NodeProp.TOTAL_COST, undefined)).toBe("N/A"); - }) - }) - - describe("rows", () => { - it("formats rows", () => { - expect(formatNodeProp(NodeProp.ACTUAL_ROWS, 1000)).toBe("1,000"); - }) - it("returns N/A for undefined", () => { - expect(formatNodeProp(NodeProp.ACTUAL_ROWS, undefined)).toBe("N/A"); - }) - }) - - describe("loops", () => { - it("formats loops", () => { - expect(formatNodeProp(NodeProp.ACTUAL_LOOPS, 1000)).toBe("1,000"); - }) - it("returns N/A for undefined", () => { - expect(formatNodeProp(NodeProp.ACTUAL_LOOPS, undefined)).toBe("N/A"); - }) - }) - - describe("factor", () => { - it("formats a factor with a times symbol", () => { - expect(formatNodeProp(NodeProp.PLANNER_ESTIMATE_FACTOR, 3.456)).toBe("3.5 ×"); - }); - - it("rounds to 2 significant figures", () => { - expect(formatNodeProp(NodeProp.PLANNER_ESTIMATE_FACTOR, 1234)).toBe("1,200 ×"); - }); - - it("returns N/A for undefined", () => { - expect(formatNodeProp(NodeProp.PLANNER_ESTIMATE_FACTOR, undefined)).toBe("N/A"); - }); - }); - - describe("kilobytes", () => { - it("formats kilobytes", () => { - expect(formatNodeProp(NodeProp.SORT_SPACE_USED, 1151688)).toBe("1.1 GB"); - }); - }); - - describe("bytes", () => { - it("formats bytes", () => { - expect(formatNodeProp(NodeProp.WAL_BYTES, 1151688)).toBe("1.1 MB"); - }); - }); - - describe("boolean", () => { - it("returns 'yes' for true", () => { - expect(formatNodeProp(NodeProp.ACTUAL_ROWS_FRACTIONAL, true)).toBe("yes"); - }); - }); - - it("returns 'no' for false", () => { - expect(formatNodeProp(NodeProp.ACTUAL_ROWS_FRACTIONAL, false)).toBe("no"); - }); - - describe("blockAsBytes", () => { - it("formats blocks", () => { - expect(formatNodeProp(NodeProp.SHARED_HIT_BLOCKS, 1234)).toBe("1,234
9.6 MB"); - }); - }); - - describe("no formatter provided", () => { - it("escapes ", () => { - expect(formatNodeProp(NodeProp.FILTER, "something")).toBe("something"); - }); - }); -}); diff --git a/src/__tests__/filters-formatProp.spec.ts b/src/__tests__/filters-formatProp.spec.ts new file mode 100644 index 00000000..23869658 --- /dev/null +++ b/src/__tests__/filters-formatProp.spec.ts @@ -0,0 +1,93 @@ +import { describe, it, expect } from "vitest" +import { formatProp } from "@/filters" +import { Property } from "@/enums" + + +describe("formatProp", () => { + describe("duration", () => { + it("formats duration", () => { + expect(formatProp(Property.ACTUAL_TOTAL_TIME, 1234.56)).toBe("1s 235ms"); + }) + it("returns N/A for undefined", () => { + expect(formatProp(Property.ACTUAL_TOTAL_TIME, undefined)).toBe("-"); + }) + }) + + describe("cost", () => { + it("formats cost", () => { + expect(formatProp(Property.TOTAL_COST, 1234.56)).toBe("1,234.56"); + }) + it("formats cost with fraction digits", () => { + expect(formatProp(Property.TOTAL_COST, 1234)).toBe("1,234.00"); + }) + it("returns N/A for undefined", () => { + expect(formatProp(Property.TOTAL_COST, undefined)).toBe("N/A"); + }) + }) + + describe("rows", () => { + it("formats rows", () => { + expect(formatProp(Property.ACTUAL_ROWS, 1000)).toBe("1,000"); + }) + it("returns N/A for undefined", () => { + expect(formatProp(Property.ACTUAL_ROWS, undefined)).toBe("N/A"); + }) + }) + + describe("loops", () => { + it("formats loops", () => { + expect(formatProp(Property.ACTUAL_LOOPS, 1000)).toBe("1,000"); + }) + it("returns N/A for undefined", () => { + expect(formatProp(Property.ACTUAL_LOOPS, undefined)).toBe("N/A"); + }) + }) + + describe("factor", () => { + it("formats a factor with a times symbol", () => { + expect(formatProp(Property.PLANNER_ESTIMATE_FACTOR, 3.456)).toBe("3.5 ×"); + }); + + it("rounds to 2 significant figures", () => { + expect(formatProp(Property.PLANNER_ESTIMATE_FACTOR, 1234)).toBe("1,200 ×"); + }); + + it("returns N/A for undefined", () => { + expect(formatProp(Property.PLANNER_ESTIMATE_FACTOR, undefined)).toBe("N/A"); + }); + }); + + describe("kilobytes", () => { + it("formats kilobytes", () => { + expect(formatProp(Property.SORT_SPACE_USED, 1151688)).toBe("1.1 GB"); + }); + }); + + describe("bytes", () => { + it("formats bytes", () => { + expect(formatProp(Property.WAL_BYTES, 1151688)).toBe("1.1 MB"); + }); + }); + + describe("boolean", () => { + it("returns 'yes' for true", () => { + expect(formatProp(Property.ACTUAL_ROWS_FRACTIONAL, true)).toBe("yes"); + }); + }); + + it("returns 'no' for false", () => { + expect(formatProp(Property.ACTUAL_ROWS_FRACTIONAL, false)).toBe("no"); + }); + + describe("blockAsBytes", () => { + it("formats blocks", () => { + expect(formatProp(Property.SHARED_HIT_BLOCKS, 1234)).toBe("1,234
9.6 MB"); + }); + }); + + describe("no formatter provided", () => { + it("escapes ", () => { + expect(formatProp(Property.FILTER, "something")).toBe("something"); + }); + }); +}); diff --git a/src/__tests__/filters-output-escape.spec.ts b/src/__tests__/filters-output-escape.spec.ts index 45db3383..17d38ebc 100644 --- a/src/__tests__/filters-output-escape.spec.ts +++ b/src/__tests__/filters-output-escape.spec.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from "vitest" -import { formatNodeProp } from "@/filters" -import { NodeProp } from "@/enums" +import { formatProp } from "@/filters" +import { Property } from "@/enums" describe("formatNodeProp", () => { test("escapes HTML in Output list items", () => { - const html = formatNodeProp(NodeProp.OUTPUT, [ + const html = formatProp(Property.OUTPUT, [ "", ]) expect(html).toContain("<img src=x onerror=alert(1)>") diff --git a/src/components/BuffersDetail.vue b/src/components/BuffersDetail.vue index 14ca6130..0be6ea92 100644 --- a/src/components/BuffersDetail.vue +++ b/src/components/BuffersDetail.vue @@ -1,7 +1,7 @@