Sha256: ec0572d08f8e0dc1e390102b1965cca35d69318026523f2d5981c858d680e752

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

var test = require('tape');
var tryit = require('../tryit');


test('basic functionality', function (t) {
    var count = 0;

    var noOp = function () {};
    var throwsError = function () {
        throw new Error('whammo');
    }

    tryit(noOp, function (e) {
        t.ok(e == null, 'should be called without an error');
    });

    tryit(throwsError, function (e) {
        t.ok('should be called');
        t.ok(e instanceof Error);
    });

    t.end();
});

test('handle case where callback throws', function (t) {
    var count = 0;

    t.throws(function () {
        tryit(function () {}, function(e) {
            count++;
            t.equal(count, 1, 'should be called once');
            throw new Error('kablowie');
        });
    }, 'should throw once');

    t.end();
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/is-resolvable/node_modules/tryit/test/test.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/is-resolvable/node_modules/tryit/test/test.js