Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should compile zero-padded numeric ranges with increments', () => {
assert.equal(compile(parse('{01..05..2}')), '(01|03|05)');
});
});
it('Parser, invalid variables with defaults', () => {
assert.equal(compile('${name:value')(), '${name:value');
assert.equal(compile('${a:bar${b:foobar}')(), '${a:barfoobar');
});
});
it('should work with null', () => {
let val = null;
let file = new File();
file.contents = val;
assert.equal(file.contents, null);
});
it('should not create an invalid posix character class:', () => {
assert.equal(convert('[:al:]'), '(?:\\[:al:\\]|[:al:])');
assert.equal(convert('[abc[:punct:][0-9]'), '(?=.)[abc\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~\\[0-9]');
});
it('max respected', () => {
let min = 100;
let max = 20000;
let n = 0;
for(let i = 0; i <= 12; i++) {
n = commonUtils.exponentialTimeWithJitter(i, min, max);
debug(`${i}: ${n}`);
}
assert.equal(n, max);
});
it('should normalize a file path', () => {
assert.equal(File.normalize(), '');
assert.equal(File.normalize('foo\\bar'), 'foo/bar');
assert.equal(File.normalize('foo\\bar\\'), 'foo/bar');
assert.equal(File.normalize('foo/bar/'), 'foo/bar');
});
});
it('generateOcspRequest - no x509 & no pem combinations', async () => {
const issuerCertUrl = cred.certData.issuer.issuerCertUrl;
assert(issuerCertUrl);
const certName = issuerCertUrl.substring(issuerCertUrl.lastIndexOf('/') + 1);
const pemPath = path.join(config.issuerCertsPath, `${certName.substring(0, certName.lastIndexOf('.'))}.pem`);
assert(DirectoryServices.doesPathExists(pemPath));
let res = ocspUtils.generateOcspRequest(cred.fqdn, cred.X509, null);
assert.equal(res, null);
res = ocspUtils.generateOcspRequest(cred.fqdn, null, pemPath);
assert.equal(res, null);
res = ocspUtils.generateOcspRequest(cred.fqdn, null, null);
assert.equal(res, null);
res = ocspUtils.generateOcspRequest();
assert.equal(res, null);
});
it('should support sync helpers by default', async () => {
pages.options.asyncHelpers = false;
const upper = str => str.toUpperCase();
pages.helper('upper', upper);
assert.equal(pages.helper('upper').helper.toString(), upper.toString());
const page = pages.get('a.hbs');
await pages.render(page);
assert.equal(page.contents.toString(), 'a BRIAN b');
assert.equal(pages.ids.size, 0);
});
it('should render multiple nested template literals', async () => {
assert.equal(await render('${4:${homepage:https://github.com/${6:${username}}}}'), 'https://github.com/');
assert.equal(await render('${homepage:https://github.com/${6:${username}}}'), 'https://github.com/');
assert.equal(await render('${homepage:https://github.com/${6:${username}}}', { homepage: 'https://github.com/jonschlinkert'}), 'https://github.com/jonschlinkert');
assert.equal(await render('${homepage:https://github.com/${6:${username}}}', { username: 'jonschlinkert'}), 'https://github.com/jonschlinkert');
assert.equal(await render('${homepage:https://github.com/${6:${username}}}', { username: 'jonschlinkert', homepage: 'https://github.com/doowb' }), 'https://github.com/doowb');
assert.equal(await render('${foo:before ${ABC} middle ${XYZ} after}', { ABC: 'one', XYZ: 'two' }), 'before one middle two after');
assert.equal(await render('${foo:before ${ABC} middle ${XYZ} after}', { foo: 'bar' }), 'bar');
});
it('should set base to given value', () => {
let val = '/';
let file = new File({ base: val });
assert.equal(file.base, val);
});
});