From 86f905f7277c024ad8cc77f4390c878618add2e9 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Thu, 7 Feb 2019 10:58:54 +0100 Subject: [PATCH 1/4] NOJIRA: Routine update of dependencies. --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index c2c5c3f..6c41c58 100644 --- a/package.json +++ b/package.json @@ -9,17 +9,17 @@ }, "repository": "https://github.com/GPII/gpii-binder", "dependencies": { - "infusion": "3.0.0-dev.20181030T133624Z.f977b0fa9" + "infusion": "3.0.0-dev.20181204T213346Z.2ca90f6e6" }, "devDependencies": { - "eslint": "5.9.0", + "eslint": "5.13.0", "eslint-config-fluid": "1.3.0", "gpii-grunt-lint-all": "1.0.5", - "gpii-testem": "2.1.6", + "gpii-testem": "2.1.7", "grunt": "1.0.3", "node-jqunit": "1.1.8", "qunitjs": "2.4.1", - "rimraf": "2.6.2", + "rimraf": "2.6.3", "testem": "2.12.0" } } From 9b324b8844430063645a71f4280babe45766cae1 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Thu, 7 Feb 2019 10:59:32 +0100 Subject: [PATCH 2/4] GPII-3699: Updated form->model relay to ensure that only one change is fired. --- src/js/binder.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/js/binder.js b/src/js/binder.js index 38579d2..8c7e212 100644 --- a/src/js/binder.js +++ b/src/js/binder.js @@ -29,14 +29,15 @@ */ gpii.binder.changeModelValue = function (that, path, elementValue) { var transformedValue = gpii.binder.transformPathedValue(that, path, elementValue, "domToModel"); - var changes = []; - changes.push({ path: path, type: "DELETE"}); + + var transaction = that.applier.initiate(); + transaction.fireChangeRequest({ path: path, type: "DELETE"}); if (transformedValue !== null && transformedValue !== undefined) { - changes.push({ path: path, value: transformedValue }); + transaction.fireChangeRequest({ path: path, value: transformedValue }); } - fluid.fireChanges(that.applier, changes); + transaction.commit(); }; /** From 778a70f8abe097d7942ecb1cd5af124e74056cb5 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Thu, 7 Feb 2019 11:35:17 +0100 Subject: [PATCH 3/4] GPII-3699: Added test to confirm that only one model change occurs per form update. --- tests/static/js/tests-fixtures.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/static/js/tests-fixtures.js b/tests/static/js/tests-fixtures.js index 8d621c1..058439f 100644 --- a/tests/static/js/tests-fixtures.js +++ b/tests/static/js/tests-fixtures.js @@ -9,18 +9,36 @@ "use strict"; var gpii = fluid.registerNamespace("gpii"); + fluid.registerNamespace("gpii.tests.binder.base"); + + gpii.tests.binder.base.tallyUpdates = function (that, path) { + console.log("tallying a model change to '" + path + "'."); + var currentCount = fluid.get(that.updateCounter, path) || 0; + currentCount++; + fluid.set(that.updateCounter, path, currentCount); + }; + // Base viewComponent used in most tests. fluid.defaults("gpii.tests.binder.base", { gradeNames: ["gpii.binder.bindOnCreate"], model: { initFromModel: "initialized from model" // The markup will be initialized with this value. }, + members: { + updateCounter: {} + }, selectors: { initFromModel: "[name='init-from-model']", initFromMarkup: "[name='init-from-markup']", updateFromModel: "[name='update-from-model']", updateFromMarkup: "[name='update-from-markup']", missingElement: ".not-found-at-all" + }, + modelListeners: { + "*": { + funcName: "gpii.tests.binder.base.tallyUpdates", + args: ["{that}", "{change}.path"] + } } }); @@ -115,9 +133,14 @@ name: "Common tests for gpii-binder...", tests: [ { - name: "Confirm that a form update results in a model update...", + name: "Confirm that a form update results in a single model update...", type: "test", sequence: [ + // The value should have been changed once based on the value of the markup. + { + funcName: "jqUnit.assertEquals", + args: ["There should have been one initial model relay to populate the field.", 1, "{testEnvironment}.binder.updateCounter.updateFromMarkup"] + }, { func: "fluid.changeElementValue", args: ["[name='update-from-markup']", "updated via form element"] @@ -125,6 +148,11 @@ { func: "jqUnit.assertEquals", args: [ QUnit.config.currentModule + ": Model data should be correctly updated after a form field change...", "updated via form element", "{testEnvironment}.binder.model.updateFromMarkup"] + }, + // The tally should now indicate that the value has been updated twice. + { + funcName: "jqUnit.assertEquals", + args: ["There should have been one additional model relay based on the form change.", 2, "{testEnvironment}.binder.updateCounter.updateFromMarkup"] } ] }, From 0e382a8a9173917a24b8540ed727c5f8e4ebe213 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Tue, 12 Feb 2019 10:38:21 +0100 Subject: [PATCH 4/4] GPII-3706: Updated testem to pick up missing `nyc` dependency. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c41c58..d1bec40 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "eslint": "5.13.0", "eslint-config-fluid": "1.3.0", "gpii-grunt-lint-all": "1.0.5", - "gpii-testem": "2.1.7", + "gpii-testem": "2.1.8-dev.20190212T093057Z.dbd30b2.GPII-3706", "grunt": "1.0.3", "node-jqunit": "1.1.8", "qunitjs": "2.4.1",