From ffef2e92fc1226acfa7f6010a66a49f336f77a9b Mon Sep 17 00:00:00 2001 From: Karishma Chadha Date: Wed, 31 Oct 2018 19:20:13 -0400 Subject: [PATCH] Fix up docs and incorrect initialization of cloud data manager functions. Add 'spec' unit tests that the cloud data manager functions are actually functions. --- src/engine/runtime.js | 12 ++++++++---- test/unit/engine_runtime.js | 8 ++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index db565edbf..95d07aa09 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -75,10 +75,14 @@ const ArgumentTypeMap = (() => { * 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. * @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. - * @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. + * @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 * cloud variables. */ - this.hasCloudData = newCloudDataManager.hasCloudVariables(); + this.hasCloudData = newCloudDataManager.hasCloudVariables; /** * 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. * @type {function} */ - this.removeCloudVariable = newCloudDataManager.removeCloudVariable(); + this.removeCloudVariable = newCloudDataManager.removeCloudVariable; } /** diff --git a/test/unit/engine_runtime.js b/test/unit/engine_runtime.js index eab8e6ea4..4fd56416b 100644 --- a/test/unit/engine_runtime.js +++ b/test/unit/engine_runtime.js @@ -11,6 +11,13 @@ test('spec', t => { t.type(Runtime, 'function'); 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.end(); @@ -154,6 +161,7 @@ test('Cloud variable limit allows only 8 cloud variables', t => { rt.removeCloudVariable(); t.equal(rt.canAddCloudVariable(), true); + rt.addCloudVariable(); t.equal(rt.canAddCloudVariable(), false); // Disposing of the runtime should reset the cloud variable limitations