summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-12 12:17:30 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-12 12:17:46 +0100
commit13d7c09125f8eec703d0a43a9a87fc8aa08f7319 (patch)
tree70fd643c429cea5c1f9362c2674511d17a53f3b5 /Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js
parentdc28c07fa526841e05e16161c74a6c23984f1dd5 (diff)
downloadserenity-13d7c09125f8eec703d0a43a9a87fc8aa08f7319.zip
Libraries: Move to Userland/Libraries/
Diffstat (limited to 'Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js')
-rw-r--r--Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js38
1 files changed, 0 insertions, 38 deletions
diff --git a/Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js b/Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js
deleted file mode 100644
index 156edffee7..0000000000
--- a/Libraries/LibJS/Tests/builtins/JSON/JSON.stringify-replacer.js
+++ /dev/null
@@ -1,38 +0,0 @@
-test("basic functionality", () => {
- let o = {
- var1: "foo",
- var2: 42,
- arr: [
- 1,
- 2,
- {
- nested: {
- hello: "world",
- },
- get x() {
- return 10;
- },
- },
- ],
- obj: {
- subarr: [3],
- },
- };
-
- let string = JSON.stringify(o, (key, value) => {
- if (key === "hello") return undefined;
- if (value === 10) return 20;
- if (key === "subarr") return [3, 4, 5];
- return value;
- });
-
- expect(string).toBe(
- '{"var1":"foo","var2":42,"arr":[1,2,{"nested":{},"x":20}],"obj":{"subarr":[3,4,5]}}'
- );
-
- string = JSON.stringify(o, ["var1", "var1", "var2", "obj"]);
- expect(string).toBe('{"var1":"foo","var2":42,"obj":{}}');
-
- string = JSON.stringify(o, ["var1", "var1", "var2", "obj", "subarr"]);
- expect(string).toBe('{"var1":"foo","var2":42,"obj":{"subarr":[3]}}');
-});