mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
* first action! (#1)
This commit is contained in:
parent
8deacc95b1
commit
ace1e6a69a
3750 changed files with 1155519 additions and 0 deletions
32
node_modules/json-parse-helpfulerror/test/test.js
generated
vendored
Normal file
32
node_modules/json-parse-helpfulerror/test/test.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
var Code = require('code'),
|
||||
Lab = require('lab'),
|
||||
lab = Lab.script(),
|
||||
jph = require('..'); // 'json-parse-helpfulerror'
|
||||
|
||||
exports.lab = lab;
|
||||
|
||||
lab.test('can parse', function (done) {
|
||||
var o = jph.parse('{"foo": "bar"}');
|
||||
|
||||
Code.expect(o.foo).to.equal('bar');
|
||||
done();
|
||||
});
|
||||
|
||||
lab.test('helpful error for bad JSON', function (done) {
|
||||
|
||||
var bad = "{'foo': 'bar'}";
|
||||
|
||||
Code.expect(function () { JSON.parse(bad) }).to.throw();
|
||||
|
||||
Code.expect(function () { jph.parse(bad) }).to.throw(SyntaxError, "Unexpected token '\\'' at 1:2\n" + bad + '\n ^');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
lab.test('fails if reviver throws', function (done) {
|
||||
function badReviver() { throw new ReferenceError('silly'); }
|
||||
|
||||
Code.expect(function () { jph.parse('3', badReviver) }).to.throw(ReferenceError, 'silly');
|
||||
|
||||
done();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue