mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Tests, 90% coverage
This commit is contained in:
1 parent
a7fcde60b8
commit
dbf209de61
3 files changed
+23
-1
No files matched your search
@@ -0,0 +1,20 @@
|
||||
const isJson = require("./isJson");
|
||||
const assert = require("assert");
|
||||
|
||||
describe("isJson.js()", function(){
|
||||
it("checks if a thing is valid JSON", function(){
|
||||
assert(isJson("string") === false);
|
||||
assert(isJson("{js_object_notation='very false'}") === false);
|
||||
assert(isJson('{ "name":"John", "age":31, "city":"New York" }') === true);
|
||||
});
|
||||
it("recognizes that true and false are both valid JSON", function(){
|
||||
assert(isJson(true) === true);
|
||||
assert(isJson(false) === true);
|
||||
});
|
||||
it("Handles null as valid JSON (after spec)", function(){
|
||||
assert(isJson(null) === true);
|
||||
});
|
||||
it("Recognizes that JSON doesn't allow trailing commas (,)", function(){
|
||||
assert(isJson('["a", "b", ]') === false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user