Fix up docs and incorrect initialization of cloud data manager functions. Add 'spec' unit tests that the cloud data manager functions are actually functions.

This commit is contained in:
Karishma Chadha 2018-10-31 19:20:13 -04:00
parent 1df6743a5f
commit ffef2e92fc
2 changed files with 16 additions and 4 deletions

View file

@ -75,10 +75,14 @@ const ArgumentTypeMap = (() => {
* A pair of functions used to manage the cloud variable limit, * A pair of functions used to manage the cloud variable limit,
* to be used when adding (or attempting to add) or removing a cloud variable. * to be used when adding (or attempting to add) or removing a cloud variable.
* @typedef {object} CloudDataManager * @typedef {object} CloudDataManager
* @property {function} canAddNewCloudVariable A function to call to check that * @property {function} canAddCloudVariable A function to call to check that
* a cloud variable can be added. * a cloud variable can be added.
* @property {function} removeExistingCloudVariable A function to call when * @property {function} addCloudVariable A function to call to track a new
* cloud variable on the runtime.
* @property {function} removeCloudVariable A function to call when
* removing an existing cloud variable. * removing an existing cloud variable.
* @property {function} hasCloudVariables A function to call to check that
* the runtime has any cloud variables.
*/ */
/** /**
@ -336,7 +340,7 @@ class Runtime extends EventEmitter {
* @return {boolean} Whether or not the runtime currently has any * @return {boolean} Whether or not the runtime currently has any
* cloud variables. * cloud variables.
*/ */
this.hasCloudData = newCloudDataManager.hasCloudVariables(); this.hasCloudData = newCloudDataManager.hasCloudVariables;
/** /**
* A function which checks whether a new cloud variable can be added * A function which checks whether a new cloud variable can be added
@ -358,7 +362,7 @@ class Runtime extends EventEmitter {
* when removing a cloud variable. * when removing a cloud variable.
* @type {function} * @type {function}
*/ */
this.removeCloudVariable = newCloudDataManager.removeCloudVariable(); this.removeCloudVariable = newCloudDataManager.removeCloudVariable;
} }
/** /**

View file

@ -11,6 +11,13 @@ test('spec', t => {
t.type(Runtime, 'function'); t.type(Runtime, 'function');
t.type(r, 'object'); t.type(r, 'object');
// Test types of cloud data managing functions
t.type(r.hasCloudData, 'function');
t.type(r.canAddCloudVariable, 'function');
t.type(r.addCloudVariable, 'function');
t.type(r.removeCloudVariable, 'function');
t.ok(r instanceof Runtime); t.ok(r instanceof Runtime);
t.end(); t.end();
@ -154,6 +161,7 @@ test('Cloud variable limit allows only 8 cloud variables', t => {
rt.removeCloudVariable(); rt.removeCloudVariable();
t.equal(rt.canAddCloudVariable(), true); t.equal(rt.canAddCloudVariable(), true);
rt.addCloudVariable();
t.equal(rt.canAddCloudVariable(), false); t.equal(rt.canAddCloudVariable(), false);
// Disposing of the runtime should reset the cloud variable limitations // Disposing of the runtime should reset the cloud variable limitations