'extended cases' : function() { var array = [ { value : 'T800' } ]; assert(optionOf('0.value', array) === 'T800'); assert(optionOf('0.values', array, 0) === 0); assert(optionOf('1.value', array, 'T1000') === 'T1000'); // test against global options assert(optionOf('option', {}) === null); optionOf.setOptions({ defaultValue : false }); assert(optionOf('option', {}) === false); optionOf.setOptions({ defaultValue : null }); optionOf.setOptions({}); },
it('should not create or destroy database', function () { var db = null, attr = new Attr(); attr._partitioner = { // fake _dbName: 'not' + System.DB_NAME, createAnotherDatabase: function (dbName) { // mock creation db = dbName; return Promise.resolve(); }, destroyAnotherDatabase: function (dbName) { // mock creation db = dbName; return Promise.resolve(); } }; attr._params = { // fake name: System.DB_ATTR_NAME, value: { action: 'add', name: 'mydb' } }; return attr.setOptions().then(function () { (db === null).should.eql(true); }); });
DriverInstance.prototype.initDriver = function() { var self = this; var driverObject; // Identify the appropriate driver var driverName = self['bm:driverName']; if (!_.contains(availableDrivers, driverName)) { throw new Error('Driver ' + driverName + ' does not exist.'); } // Construct the driver driverObject object var constructor = require(driverName); if (self.driverObject && self.driverObject.constructor === constructor) { return; } self.log('info', 'Initialising...'); driverObject = new constructor(); driverObject.setOptions(self.options); self.driverObject = driverObject; self.attachEvents(); self.log('finish', 'Initialised.'); };
it('should emit OptionsRequiredError if no options passed', function () { var npmTemplate = new NpmTemplate(), errorSpy = sinon.spy(); npmTemplate.on('error', errorSpy); npmTemplate.setOptions(); expect(errorSpy).to.be.calledOnce; });
it('should emit OptionsRequiredError if no options passed', function () { var awesome = new Awesome(), errorSpy = sinon.spy(); awesome.on('error', errorSpy); awesome.setOptions(); expect(errorSpy).to.be.calledOnce; });
module.exports = function(args, callback) { let flow = require(path.join(process.cwd(), args.flow)); if (args.params) { flow.setOptions(args.params); } flow.execute((err, result) => { if (err) return callback(err); logger.logJSON(result); }); }
#!/usr/bin/env node /* JSON 3 Builder | http://bestiejs.github.com/json3 */ var path = require("path"), fs = require("fs"), gzip = require("zlib").gzip, spawn = require("child_process").spawn, marked = require(path.join(__dirname, "vendor", "marked")), // The path to the Closure Compiler `.jar` file. closurePath = path.join(__dirname, "vendor", "closure-compiler.jar"), // The Closure Compiler options: enable advanced optimizations and suppress all // warnings apart from syntax and optimization errors. closureOptions = ["--compilation_level=ADVANCED_OPTIMIZATIONS", "--warning_level=QUIET"]; // Enable GitHub-Flavored Markdown. marked.setOptions({ "gfm": true }); // Generate the GitHub project page. fs.readFile(path.join(__dirname, "README.md"), "utf8", function readInfo(exception, source) { if (exception) { console.log(exception); } else { // Read the project page template. fs.readFile(path.join(__dirname, "page", "page.html"), "utf8", readTemplate); } // Interpolates the page template and writes the result to disk. function readTemplate(exception, page) { var headers, lines, lastSection, lastLevel, navigation; if (exception) { console.log(exception); } else { // Generate the page navigation. Ported from `mdtoc.rb` by Sam