File: test/functional/support/availability.js
'use strict';
var _ = require('lodash');
var logger = require('../../../node_modules/ice-grunt/grunt/logger.js').getLogger();
var createCallback = function (done) {
return function (err, result) {
result = result || {};
//logger.debug('command result:', result.value);
done(err, result.value, result);
};
};
var addCreateAvailabilityCommand = function (client) {
/**
* Creates an instance of tooltip
* @method createTooltip
*/
client.addCommand('createAvailability', function (options, done) {
logger.debug('creating an instance of availability');
this.execute(function (options) {
ICE.ISMDSPlugin.create(window.ice, options);
}, options, createCallback(done));
});
};
var addSetAvailabilityCommand = function (client) {
/**
* change the availability of all seats in a given section
* @method setRowAvailability Sets the availability for all places in a row to the status passed
* @param {object} options
* @param {string} section Name of Section
* @param {string} row Name of row
* @param {string} invType Inventory type
*/
client.addCommand('setRowAvailability', function (options, done) {
logger.debug('set ability of a section');
this.execute(function (options) {
var invType = options.invType;
var section = ICE._.find(ice.data.segmentsByCategory["SECTION"], {
name: options.section
});
var row = ICE._.find(section.segments, {
name: options.row
});
ICE._.forEach(row.places, function (place) {
place[invType] = options.invType;
});
}, options, createCallback(done));
});
};
module.exports = {
extend: function (client) {
addCreateAvailabilityCommand(client);
addSetAvailabilityCommand(client);
}
};