2025-12-18 13:35:48 -06:00
|
|
|
import {Array} from "./array.js";
|
|
|
|
|
import {Dictionary} from "./dictionary.js";
|
|
|
|
|
import {Null} from "./null.js";
|
|
|
|
|
import {NumberData} from "./number.js";
|
|
|
|
|
import {replacer} from "./replacer.js";
|
|
|
|
|
import {StringData} from "./string.js";
|
2023-01-06 15:54:31 -08:00
|
|
|
|
|
|
|
|
describe("replacer", () => {
|
|
|
|
|
it("null", () => {
|
|
|
|
|
expect(JSON.stringify(new Null(), replacer, " ")).toEqual("null");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("array", () => {
|
2023-01-09 19:02:19 -05:00
|
|
|
expect(JSON.stringify(new Array(new StringData("a"), new StringData("b")), replacer, " ")).toEqual(
|
|
|
|
|
'[\n "a",\n "b"\n]'
|
|
|
|
|
);
|
2023-01-06 15:54:31 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("dictionary", () => {
|
2023-01-09 19:02:19 -05:00
|
|
|
expect(JSON.stringify(new Dictionary({key: "a", value: new NumberData(42)}), replacer, " ")).toEqual(
|
|
|
|
|
'{\n "a": 42\n}'
|
|
|
|
|
);
|
2023-01-06 15:54:31 -08:00
|
|
|
});
|
|
|
|
|
});
|