Skip to content

Commit

Permalink
Merge branch 'GPII-4479'
Browse files Browse the repository at this point in the history
* GPII-4479:
  GPII-4479: Further updated dependencies to pick up recent releases.
  GPII-4479: Updated to infusion with resource loader fix.
  GPII-4479: Tidied up lazy plain require of the package.
  GPII-4479: Update to work with newer versions of Infusion.
  • Loading branch information
amb26 committed May 26, 2020
2 parents a8f54b6 + 3929d4a commit 3290367
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 26 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
"author": "Tony Atkins <[email protected]>",
"license": "BSD-3-Clause",
"dependencies": {
"ajv": "6.10.2",
"gpii-binder": "1.0.6",
"ajv": "6.12.2",
"gpii-binder": "1.1.0",
"gpii-express": "1.0.15",
"gpii-handlebars": "2.1.0-dev.20191014T141924Z.45a74ef.GPII-4100",
"infusion": "3.0.0-dev.20191009T141140Z.32c9263b4.FLUID-6148",
"kettle": "1.11.0"
"gpii-handlebars": "2.1.1",
"infusion": "3.0.0-dev.20200525T143422Z.f7f6aab.FLUID-6148",
"kettle": "1.12.0"
},
"devDependencies": {
"eslint": "6.5.1",
"eslint": "7.1.0",
"eslint-config-fluid": "1.4.0",
"foundation-sites": "6.4.1",
"gpii-grunt-lint-all": "1.0.5",
"gpii-testem": "2.1.11-dev.20191003T113129Z.477bcc0.GPII-4156",
"grunt": "1.0.4",
"handlebars": "4.4.3",
"markdown-it": "10.0.0",
"mkdirp": "0.5.1",
"foundation-sites": "6.6.3",
"gpii-grunt-lint-all": "1.0.7",
"gpii-testem": "2.1.12",
"grunt": "1.1.0",
"handlebars": "4.7.6",
"markdown-it": "11.0.0",
"mkdirp": "1.0.4",
"node-jqunit": "1.1.8",
"nyc": "14.1.1",
"request": "2.88.0",
"rimraf": "3.0.0",
"testem": "2.17.0"
"nyc": "15.0.1",
"request": "2.88.2",
"rimraf": "3.0.2",
"testem": "3.1.0"
}
}
3 changes: 2 additions & 1 deletion src/js/common/schemaValidatedModelComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ var fluid = fluid || require("infusion");
},
modelListeners: {
"*": {
namespace: "validateModel",
excludeSource: ["init", "validation"],
funcName: "gpii.schema.modelComponent.validateModel",
args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent
}
},
listeners: {
"onCreate.validate": {
"onCreate.validateModel": {
funcName: "gpii.schema.modelComponent.validateModel",
args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>

<!-- The tests -->
<script src="../js/common/lib/check-potentia-grades.js"></script>
<script src="../js/common/schema-validated-component-pre-potentia-ii-tests.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>

<!-- The tests -->
<script src="../js/common/lib/check-potentia-grades.js"></script>
<script src="../js/common/schema-validated-component-tests.js"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions tests/js/common/lib/check-potentia-grades.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* globals require */
/* eslint-env browser */
var fluid = fluid || {};

(function (fluid) {
"use strict";
if (!fluid.identity) {
fluid = require("infusion");
fluid.require("%gpii-json-schema");
}

var gpii = fluid.registerNamespace("gpii");

fluid.registerNamespace("gpii.test.schema");

/**
*
* Confirm that the context-based approach to handling both potentia-ii and mainline Infusion is working.
* @param {Object} component - The component to be inspected.
* @param {Object} jqUnit - The instance of jqUnit to use to check assertions.
*
*/
gpii.test.schema.checkContextGrades = function (component, jqUnit) {
var isPotentiaTwo = gpii.schema.component.hasRegisterPotentia();

if (isPotentiaTwo) {
jqUnit.assertTrue("The resulting component should have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII"));
jqUnit.assertFalse("The resulting component should not have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy"));
}
else {
jqUnit.assertFalse("The resulting component should not have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII"));
jqUnit.assertTrue("The resulting component should have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy"));
}
};
})(fluid);
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var jqUnit = jqUnit || {};
fluid = require("infusion");
jqUnit = require("node-jqunit");
require("../../../src/js/common/schemaValidatedComponent");
require("./lib/check-potentia-grades");
}
var gpii = fluid.registerNamespace("gpii");

Expand Down Expand Up @@ -48,8 +49,7 @@ var jqUnit = jqUnit || {};
var component = gpii.tests.schemaValidatedComponent.legacy.component({ mustHave: true });
jqUnit.assert("We should have been able to instantiate our custom component with valid options.");

jqUnit.assertTrue("The resulting component should have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII"));
jqUnit.assertFalse("The resulting component should not have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy"));
gpii.test.schema.checkContextGrades(component, jqUnit);
});

jqUnit.test("Testing invalid component options.", function () {
Expand Down
4 changes: 2 additions & 2 deletions tests/js/common/schema-validated-component-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var jqUnit = jqUnit || {};
fluid = require("infusion");
jqUnit = require("node-jqunit");
require("../../../src/js/common/schemaValidatedComponent");
require("./lib/check-potentia-grades");
}
var gpii = fluid.registerNamespace("gpii");

Expand Down Expand Up @@ -38,8 +39,7 @@ var jqUnit = jqUnit || {};
var component = gpii.tests.schema.valid({ newBoolean: true });
jqUnit.assert("We should have been able to instantiate our custom component with valid options.");

jqUnit.assertTrue("The resulting component should have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII"));
jqUnit.assertFalse("The resulting component should not have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy"));
gpii.test.schema.checkContextGrades(component, jqUnit);
});

jqUnit.test("Testing invalid component options.", function () {
Expand Down
38 changes: 34 additions & 4 deletions tests/js/common/schema-validated-modelComponent-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,45 @@ var jqUnit = jqUnit || {};

var gpii = fluid.registerNamespace("gpii");

fluid.defaults("gpii.tests.schema.modelComponent", {
gradeNames: ["gpii.schema.modelComponent"],
members: {
validationPasses: 0
},
modelListeners: {
"*": {
namespace: "validateModel",
excludeSource: ["init", "validation"],
funcName: "gpii.tests.schema.modelComponent.trackedModelValidation",
args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent
}
},
listeners: {
"onCreate.validateModel": {
funcName: "gpii.tests.schema.modelComponent.trackedModelValidation",
args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent
}
}
});

gpii.tests.schema.modelComponent.trackedModelValidation = function (globalValidator, validatedModelComponent) {
validatedModelComponent.validationPasses++;
gpii.schema.modelComponent.validateModel(globalValidator, validatedModelComponent);
};

jqUnit.module("Schema validated model component tests.");

jqUnit.test("Testing the base grade.", function () {
var component = gpii.schema.modelComponent();
var component = gpii.tests.schema.modelComponent();
jqUnit.assert("We should have been able to instantiate an instance of the base gpii.schema.component grade successfully.");

jqUnit.assertEquals("There should have been a single validation pass on component startup.", 1, component.validationPasses);

jqUnit.assertLeftHand("The initial model should be valid.", { isValid: true }, component.model.validationResults);
});

fluid.defaults("gpii.tests.schemaValidatedModelComponent.basicValidation",{
gradeNames: ["gpii.schema.modelComponent"],
gradeNames: ["gpii.tests.schema.modelComponent"],
modelSchema: {
properties: {
validModelVariableIsValid: {
Expand All @@ -41,12 +70,12 @@ var jqUnit = jqUnit || {};
var component = gpii.tests.schemaValidatedModelComponent.basicValidation();
jqUnit.assert("We should have been able to instantiate an instance of our grade successfully.");

// This may be need to be removed to avoid timing problems, the next test is a more meaningful test of initial vs. subsequent validation.
jqUnit.assertLeftHand("The initial model should be valid.", { isValid: true }, component.model.validationResults);
jqUnit.assertEquals("There should have been a single validation pass on component startup.", 1, component.validationPasses);

component.applier.modelChanged.addListener({ path: "validationResults"}, function (validationResults) {
jqUnit.start();
jqUnit.assertLeftHand("The updated model should be invalid.", { isValid: false }, validationResults);
jqUnit.assertEquals("There should have been a second validation pass on a model change.", 2, component.validationPasses);
});

jqUnit.stop();
Expand All @@ -62,6 +91,7 @@ var jqUnit = jqUnit || {};
jqUnit.start();
jqUnit.assertLeftHand("The old model should be invalid.", { isValid: false }, oldValidationResults);
jqUnit.assertLeftHand("The new model should be valid.", { isValid: true }, newValidationResults);
jqUnit.assertEquals("There should have been a second validation pass on a model change.", 2, component.validationPasses);
});

jqUnit.stop();
Expand Down

0 comments on commit 3290367

Please sign in to comment.