How to use the assert.doesNotThrow function in assert

To help you get started, we’ve selected a few assert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ben-ng / minifyify / test / bundles.js View on Github external
function validateApp(min, map) {
    // Write to the build dir
    var appdir = path.join(fixtures.buildDir, 'apps', appname);

    utils.file.mkdirP( appdir, {silent: true});

    utils.file.cpR(fixtures.scaffoldDir
      , path.join(fixtures.buildDir, 'apps'), {rename:appname, silent:true});
    utils.file.cpR(path.dirname(fixtures.entryScript(appname))
      , path.join(fixtures.buildDir, 'apps'), {rename:appname, silent:true});
    fs.writeFileSync( path.join(destdir, path.basename(filename)), min );
    fs.writeFileSync( path.join(destdir, path.basename(mapname)), map );

    assert.doesNotThrow(function () {
      validate(min, map);
    }, appname + ' should not throw');

    cb();
  }
github apigee / trireme / node12 / node12tests / simple / test-assert.js View on Github external
assert.doesNotThrow(makeBlock(a.deepEqual, /a/m, /a/m));
assert.doesNotThrow(makeBlock(a.deepEqual, /a/igm, /a/igm));
assert.throws(makeBlock(a.deepEqual, /ab/, /a/));
assert.throws(makeBlock(a.deepEqual, /a/g, /a/));
assert.throws(makeBlock(a.deepEqual, /a/i, /a/));
assert.throws(makeBlock(a.deepEqual, /a/m, /a/));
assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im));

var re1 = /a/;
re1.lastIndex = 3;
assert.throws(makeBlock(a.deepEqual, re1, /a/));


// 7.4
assert.doesNotThrow(makeBlock(a.deepEqual, 4, '4'), 'deepEqual == check');
assert.doesNotThrow(makeBlock(a.deepEqual, true, 1), 'deepEqual == check');
assert.throws(makeBlock(a.deepEqual, 4, '5'),
              a.AssertionError,
              'deepEqual == check');

// 7.5
// having the same number of owned properties && the same set of keys
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4}, {a: 4}));
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '2'}, {a: 4, b: '2'}));
assert.doesNotThrow(makeBlock(a.deepEqual, [4], ['4']));
assert.throws(makeBlock(a.deepEqual, {a: 4}, {a: 4, b: true}),
              a.AssertionError);
assert.doesNotThrow(makeBlock(a.deepEqual, ['a'], {0: 'a'}));
//(although not necessarily the same order),
assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4}));
var a1 = [1, 2, 3];
var a2 = [1, 2, 3];
github mceSystems / node-jsc / test / parallel / test-assert.js View on Github external
assert.doesNotThrow(makeBlock(a.notEqual, true, false),
                    'notEqual(true, false)');

assert.throws(makeBlock(a.notEqual, true, true),
              a.AssertionError, 'notEqual(true, true)');

assert.throws(makeBlock(a.strictEqual, 2, '2'),
              a.AssertionError, 'strictEqual(2, \'2\')');

assert.throws(makeBlock(a.strictEqual, null, undefined),
              a.AssertionError, 'strictEqual(null, undefined)');

assert.throws(makeBlock(a.notStrictEqual, 2, 2),
              a.AssertionError, 'notStrictEqual(2, 2)');

assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'),
                    'notStrictEqual(2, \'2\')');

// deepEqual joy!
assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14),
                              new Date(2000, 3, 14)),
                    'deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))');

assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)),
              a.AssertionError,
              'deepEqual(new Date(), new Date(2000, 3, 14))');

assert.throws(
  makeBlock(a.notDeepEqual, new Date(2000, 3, 14), new Date(2000, 3, 14)),
  a.AssertionError,
  'notDeepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'
);
github oculus42 / short-uuid / test / index.js View on Github external
it('should be a constructor function', function(){

        var b90;
        assert.ok(typeof short === 'function');

        assert.doesNotThrow(function(){
            b90 = short(short.constants.cookieBase90);
        }, "Calling does not throw an error");

        assert.equal(typeof b90, 'object', "constructor returns an object");
    });
github sebbo2002 / ical-generator / test / test_0.2.x.js View on Github external
it('should not require optional parameters', function() {
                assert.doesNotThrow(function() {
                    ical().addEvent({
                        start: new Date(),
                        summary: 'Patch-Day'
                    });
                }, Error);
            });
        });
github mikegerwitz / easejs / test / test-util-prop-parse.js View on Github external
( function testTriggersErrorIfInvalidVarNamesAreUsedAsParameterNames()
{
    assert['throws']( function()
    {
        util.propParse( { 'abstract foo': [ 'invalid name' ] }, {} );
    }, SyntaxError, 'Only var names should be permitted in interface dfns' );

    assert['throws']( function()
    {
        util.propParse( { 'abstract foo': [ '1invalid' ] }, {} );
    }, SyntaxError, 'Only var names should be permitted in interface dfns: 2' );

    assert.doesNotThrow( function()
    {
        util.propParse( { 'abstract foo': [ 'valid_name' ] }, {} );
    }, SyntaxError, 'Valid var names as args should not throw exceptions' );
} )();
github apigee / trireme / node12 / node12tests / simple / test-assert.js View on Github external
assert.ok(common.indirectInstanceOf(a.AssertionError.prototype, Error),
          'a.AssertionError instanceof Error');

assert.throws(makeBlock(a, false), a.AssertionError, 'ok(false)');

assert.doesNotThrow(makeBlock(a, true), a.AssertionError, 'ok(true)');

assert.doesNotThrow(makeBlock(a, 'test', 'ok(\'test\')'));

assert.throws(makeBlock(a.ok, false),
              a.AssertionError, 'ok(false)');

assert.doesNotThrow(makeBlock(a.ok, true),
                    a.AssertionError, 'ok(true)');

assert.doesNotThrow(makeBlock(a.ok, 'test'), 'ok(\'test\')');

assert.throws(makeBlock(a.equal, true, false), a.AssertionError, 'equal');

assert.doesNotThrow(makeBlock(a.equal, null, null), 'equal');

assert.doesNotThrow(makeBlock(a.equal, undefined, undefined), 'equal');

assert.doesNotThrow(makeBlock(a.equal, null, undefined), 'equal');

assert.doesNotThrow(makeBlock(a.equal, true, true), 'equal');

assert.doesNotThrow(makeBlock(a.equal, 2, '2'), 'equal');

assert.doesNotThrow(makeBlock(a.notEqual, true, false), 'notEqual');

assert.throws(makeBlock(a.notEqual, true, true),
github ecto / bleach / test / analyze.js View on Github external
'does not require options to be passed in': function(sanitize){
      assert.doesNotThrow(function(){
        sanitize(' ');
      }, Error);
    },
    'returns a string': function(sanitize) {
github tddbin / katas / src / flat-metadata.spec.js View on Github external
it('can also be missing, which means it is not yet published, doh :)', () => {
      const metadataWithoutPublishDate = {...all};
      const arrayOfKata = metadataWithoutPublishDate.groups['Array API'].items[30];
      delete arrayOfKata.publishDateUTC;
      assert.doesNotThrow(() => converted(metadataWithoutPublishDate));
    });
    it('the `publishDate`, if set, is as UTC string, with GMT+0', function() {
github mako-taco / wan / lib / assertions.js View on Github external
module.exports = function (opts) {
	assert.notStrictEqual(opts, undefined, "Wan missing required paramater [options]");
	assert.notStrictEqual(opts.route, undefined, "Wan missing required option [route]");
	assert.notStrictEqual(opts.location, undefined, "Wan missing required option [location]");
	assert.doesNotThrow(function () {
		stats = fs.statSync(path.join(process.cwd(), opts.location))
	}, "Cannot access location '" + path.join(process.cwd(), opts.location) + "'");
	assert.ok(stats.isDirectory(), "Option [location] must be a directory");
}