Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('can change the image type property value to upper-case and replaces dashes with underscores', () => {
const result = Formatters.Image.type({ type: 'salisbury-steak' });
expect(result).to.equal('SALISBURY_STEAK');
});
it('can apply tagged rules for creating a machine', async () => {
const fetch = TestDouble.func();
const rule = Object.assign({}, firewallRule);
rule.rule = 'FROM tag bacon TO tag flavor=smokey ALLOW udp port 8675';
TestDouble.when(fetch('/fwrules')).thenResolve([rule]);
const tags = [{ name: 'bacon' }, { name: 'flavor', value: 'smokey' }];
const res = await FirewallRules.firewall_rules_create_machine(fetch, { tags });
expect(res).to.exist();
expect(res.length).to.equal(1);
expect(res[0].rule_obj.action).to.equal('allow');
const tag = res[0].rule_obj.from[0][1];
expect(tag).to.equal('bacon');
});
it('reduces 8.22 with the combined product of exploitability scores', function () {
var simpleScores = keys.exploitability.reduce(scoreReducer, {});
expect(scores.getExploitability(simpleScores)).to.equal(8.22 / Math.pow(2, keys.exploitability.length))
var envScores = keys.envExploitability.reduce(scoreReducer, {});
expect(scores.getExploitability(envScores, { env: true })).to.equal(8.22 / Math.pow(2, keys.envExploitability.length));
});
});
it('throws if validation fails and option.throw is truthy', function () {
expect(function () {
main.getScore(internals.vectorString.slice(4), { throw: true });
}).to.throw(Error, /Invalid vector string/);
});
it('should subscribe to retryable observable and return rx-subscription', function () {
this.primus.graphql.returns(this.observable)
var rxSubscription = this.networkLayer.sendSubscription(this.subscriptionRequest)
expect(rxSubscription).to.exist()
expect(rxSubscription.unsubscribe).to.be.a.function()
sinon.assert.calledOnce(this.backoffObservable.subscribe)
sinon.assert.calledWith(this.backoffObservable.subscribe,
expectBound(this.subscriptionRequest.onNext),
expectName('onFinalError'),
expectBound(this.subscriptionRequest.onCompleted))
})
lab.test('should not call extended two times', co.wrap(function * () {
let bookshelf = require('bookshelf')(db.bookshelf.knex)
bookshelf.plugin(require('../../'))
let Model = bookshelf.Model.extend({
tableName: 'users'
})
let error = yield Model.forge({ email: 'wont@exists' })
.fetch({ require: true })
.catch(err => err)
expect(error).to.be.instanceof(bookshelf.Model.NotFoundError)
}))
lab.test('should not be able to delete twice', co.wrap(function * () {
yield Comment.forge({ id: 1 }).destroy()
const error = yield Comment.forge({ id: 1 })
.destroy({ require: true })
.catch((err) => err)
expect(error).to.be.instanceOf(Comment.NoRowsDeletedError)
}))
it('returns an error if input is neither object nor string', function () {
var error = vector.validate(null).error;
expect(error).to.be.an.instanceOf(TypeError);
expect(error.toString()).to.contain('must be an object or string');
});
lab.test('should error if the sentinel column does not exist', co.wrap(function * () {
let bookshelf = yield customDb.altFieldTable((bookshelf) => {
bookshelf.plugin(require('../../'), { sentinel: 'active' })
})
let Model = bookshelf.Model.extend({ tableName: 'test', softDelete: true })
let err = yield Model.forge().save().catch((err) => err)
expect(err).to.be.an.error(/has no column/)
}))
lab.test('should throw when required', co.wrap(function * () {
let err = yield Comment.forge({ id: 12345 })
.destroy({ require: true })
.catch((err) => err)
expect(err).to.be.an.error('No Rows Deleted')
}))