cartodb/lib/assets/test/spec/builder/helpers/required-opts.spec.js

29 lines
733 B
JavaScript
Raw Normal View History

2020-06-15 10:58:47 +08:00
var checkAndBuildOpts = require('builder/helpers/required-opts');
describe('required opts', function () {
describe('basic usage', function () {
it('should throw if any required opt is missing', function () {
var REQUIRED_OPTS = [
'opt1',
'opt2'
];
expect(function () {
checkAndBuildOpts({ opt1: 'foo' }, REQUIRED_OPTS, {});
}).toThrow();
});
it('should set all required opts as _opt by default', function () {
var REQUIRED_OPTS = [
'opt1',
'opt2'
];
var ops = { opt1: 0, opt2: 1 };
var context = {};
checkAndBuildOpts(ops, REQUIRED_OPTS, context);
expect(context).toEqual({ _opt1: 0, _opt2: 1 });
});
});
});