How to use the assert.strict 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 beameio / beame-sdk / src / services / BeameStoreV2.js View on Github external
credential = await this.fetch(fqdn);
			}
		} else {
			assert(allowRemote, `Credential ${fqdn} was not found locally and allowRemote is false`);
			credential = await this.fetch(fqdn);
		}
		assert(credential, `Credential ${fqdn} was not found!`);

		// check validity if allowed
		if(!allowExpired) {
			credential.checkValidity();
		}

		// check ocsp status if allowed
		if(!allowRevoked) {
			assert(await credential.checkOcspStatus(credential) !== config.OcspStatus.Revoked,
				`Credential ${fqdn} is revoked and allowRevoked is false`);
		}

		return credential;
	}
github beameio / beame-sdk / tests / unit_tests / test_commonutils.js View on Github external
it('bad function that turns good without wait', async () => {
		const retries = 10;
		const errorMessage = "error on retry func";

		let fncalled = 0;
		const fn = simple.stub().callFn(function() {
			if(fncalled < 7) {
				fncalled++;
				throw new Error(errorMessage);
			}
			return true;
		});

		const result = await commonUtils.retry(fn, retries,(() => 0));
		assert.equal(fn.callCount, fncalled+1);
		assert(result);
	});
});
github beameio / beame-sdk / tests / unit_tests / test_beameutils.js View on Github external
it('double stopping fails second time', () => {
		beameUtils.startBackgroundJob(name,() => {}, 2000);
		beameUtils.stopBackgroundJob(name);
		try {
			beameUtils.stopBackgroundJob(name);
			assert.fail("Should have failed");
		}
		catch (e) {
			assert(e && e.message, "error shouldn't be empty");
		}
	});
github micromatch / picomatch / test / slashes-posix.js View on Github external
it('should match leading slashes', () => {
    assert(!isMatch('ef', '/*'));
    assert(isMatch('/ef', '/*'));
    assert(isMatch('/foo/bar.txt', '/foo/*'));
    assert(isMatch('/foo/bar.txt', '/foo/**'));
    assert(isMatch('/foo/bar.txt', '/foo/**/**/*.txt'));
    assert(isMatch('/foo/bar.txt', '/foo/**/**/bar.txt'));
    assert(isMatch('/foo/bar.txt', '/foo/**/*.txt'));
    assert(isMatch('/foo/bar.txt', '/foo/**/bar.txt'));
    assert(!isMatch('/foo/bar.txt', '/foo/*/bar.txt'));
    assert(!isMatch('/foo/bar/baz.txt', '/foo/*'));
    assert(isMatch('/foo/bar/baz.txt', '/foo/**'));
    assert(isMatch('/foo/bar/baz.txt', '/foo/**'));
    assert(isMatch('/foo/bar/baz.txt', '/foo/**/*.txt'));
    assert(isMatch('/foo/bar/baz.txt', '/foo/**/*/*.txt'));
    assert(isMatch('/foo/bar/baz.txt', '/foo/**/*/baz.txt'));
    assert(!isMatch('/foo/bar/baz.txt', '/foo/*.txt'));
    assert(isMatch('/foo/bar/baz.txt', '/foo/*/*.txt'));
    assert(!isMatch('/foo/bar/baz.txt', '/foo/*/*/baz.txt'));
    assert(!isMatch('/foo/bar/baz.txt', '/foo/bar**'));
    assert(isMatch('/foo/bar/baz/qux.txt', '**/*.txt'));
    assert(!isMatch('/foo/bar/baz/qux.txt', '**/.txt'));
github graalvm / graaljs / test / parallel / test-assert.js View on Github external
(function hidden() {
    const err = new assert.AssertionError({
      actual: 'foo',
      operator: 'strictEqual',
      stackStartFunction: hidden
    });
    const err2 = new assert.AssertionError({
      actual: 'foo',
      operator: 'strictEqual',
      stackStartFn: hidden
    });
    assert(!err.stack.includes('hidden'));
    assert(!err2.stack.includes('hidden'));
  })();
}
github Zvezdin / blockchain-predictor / data-downloader.js View on Github external
let txCount = 0;
	let blCount = 0;

	for(let bl in res['block']) {
		txCount += res['block'][bl].transactions.length;
		blCount++;
	}

	let traceCount = res['trace'].length;

	console.log("The resulting package contains "+txCount+" transactions, "+res['log'].length+" logs and "+traceCount+" traces.");
	
	//check if there have been too many traces, but only if we actually had enough transactions
	if(txCount > blCount && traceCount > txCount * 5) {
		console.error("Too many traces compared to transactions! Breaking, take a look.");
		assert(false);
	}

	let blockchain = structureBlockchainData(res['block'], res['log'], res['trace']);
	
	if(filename == null){
		filename = datadir+"blocks "+blockchain['block'][0].number+"-"+blockchain['block'][blockchain['block'].length-1].number+".json";
	}

	jsonUtil.save(blockchain, filename);
}
github taskcluster / taskcluster / libraries / postgres / src / Schema.js View on Github external
static _checkAccess(access) {
    assert(typeof access === 'object' && !(access instanceof Array),
      'access.yml should define an object');
    Object.keys(access).forEach(serviceName => {
      const serviceAccess = access[serviceName];
      assert(typeof serviceAccess === 'object' && !(serviceAccess instanceof Array),
        'each service in access.yml should define an object');
      assert.deepEqual(Object.keys(serviceAccess).sort(), ['tables'],
        'each service in access.yml should only have a `tables` property');
    });
  }
github panva / node-oidc-provider / lib / helpers / jwt.js View on Github external
if (typeof payload.nbf !== 'undefined' && !ignoreNotBefore) {
      assert.equal(typeof payload.nbf, 'number', 'invalid nbf value');
      assert(payload.nbf <= timestamp + clockTolerance, 'jwt not active yet');
    }

    if (typeof payload.iat !== 'undefined' && !ignoreIssued) {
      assert.equal(typeof payload.iat, 'number', 'invalid iat value');
      if (typeof payload.exp === 'undefined') {
        assert(payload.iat <= timestamp + clockTolerance, 'jwt issued in the future');
      }
    }

    if (typeof payload.exp !== 'undefined' && !ignoreExpiration) {
      assert.equal(typeof payload.exp, 'number', 'invalid exp value');
      assert(timestamp - clockTolerance < payload.exp, 'jwt expired');
    }

    if (typeof payload.jti !== 'undefined') {
      assert.equal(typeof payload.jti, 'string', 'invalid jti value');
    }

    if (typeof payload.iss !== 'undefined') {
      assert.equal(typeof payload.iss, 'string', 'invalid iss value');
    }

    if (jti) {
      assert.equal(payload.jti, jti, 'jwt jti invalid');
    }

    if (audience) {
      verifyAudience(