Opal-Estate-Pro/node_modules/safe-json-parse/test/index.js
2019-09-13 11:27:52 +07:00

27 lines
586 B
JavaScript

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()
})
})