Opal-Estate-Pro/node_modules/safe-json-parse/test/index.js

27 lines
586 B
JavaScript
Raw Normal View History

2019-09-13 06:27:52 +02:00
var test = require("tape")
var safeParse = require("../index")
test("safeParse is a function", function (assert) {
assert.equal(typeof safeParse, "function")
assert.end()
})
test("safeParse valid json", function (assert) {
safeParse("{ \"foo\": true }", function (err, json) {
assert.ifError(err)
assert.equal(json.foo, true)
assert.end()
})
})
test("safeParse faulty", function (assert) {
safeParse("WRONG", function (err) {
assert.ok(err)
assert.equal(err.message, "Unexpected token W")
assert.end()
})
})