-
Couldn't load subscription status.
- Fork 6
GPII-2933 Common Event Bindings #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
669e19d
e44d0f2
c6f021b
b5a1070
6e7d524
b5c2d4d
2dd12a6
3bd28a7
0be5062
d7ed31a
cb18acc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* globals fluid, jqUnit */ | ||
| (function () { | ||
| "use strict"; | ||
| var gpii = fluid.registerNamespace("gpii"); | ||
|
|
||
| // Component to test support for common event bindings | ||
| fluid.defaults("gpii.tests.binder.commonEventBindings", { | ||
| gradeNames: ["gpii.tests.binder.base", "gpii.binder.bindMarkupEvents"], | ||
| bindings: { | ||
| }, | ||
| selectors: { | ||
| inputButton: "#input-button", | ||
| paragraphClick: ".parapgraph-click" | ||
| }, | ||
| markupEventBindings: { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also supply a test which shows that these handlers can be overridden cleanly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test where 1) Some are left as is, 2) some are overridden, and 3) some new one is introduced. |
||
| inputButton: { | ||
sgithens marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| method: "click", | ||
| args: ["{that}.handleInputClick"] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Supply further tests to validate the primitive kinds of "compact" IoC syntax we support which allows for args There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this tip, I didn't know this was possibly actually, and will simplify my usage in the capture tool, PPT, and elsewhere |
||
| }, | ||
| paragraphClick: { | ||
| method: "click", | ||
| args: ["{that}.handleParagraphClick"] | ||
| } | ||
| }, | ||
| invokers: { | ||
| handleInputClick: { | ||
| funcName: "gpii.tests.binder.commonEventBindings.handleInputClick", | ||
| args: ["{arguments}.0"] | ||
| }, | ||
| handleParagraphClick: { | ||
| funcName: "gpii.tests.binder.commonEventBindings.handleParagraphClick", | ||
| args: ["{arguments}.0"] | ||
| } | ||
| }, | ||
| listeners: { | ||
| "onCreate.markupEventBindings": "{that}.events.onMarkupRendered.fire()" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the kind of thing I'd also write out, what if someone needs to do other work before firing the event? I guess they can just rewrite the whole string. |
||
| } | ||
| }); | ||
|
|
||
| gpii.tests.binder.commonEventBindings.handleInputClick = function (event) { | ||
| jqUnit.assertEquals("We just clicked an input...", "INPUT", event.target.nodeName); | ||
| }; | ||
|
|
||
| gpii.tests.binder.commonEventBindings.handleParagraphClick = function (event) { | ||
| jqUnit.assertEquals("We just clicked a paragraph...", "P", event.target.nodeName); | ||
| }; | ||
|
|
||
| fluid.defaults("gpii.tests.binder.commonEventBindings.caseHolder", { | ||
| gradeNames: ["gpii.tests.binder.caseHolder"], | ||
| rawModules: [{ | ||
| name: "Testing support for common event bindings...", | ||
| tests: [ | ||
| { | ||
| name: "Test markup event binding for click on an input button", | ||
| type: "test", | ||
| expect: 1, | ||
| sequence: [ | ||
| { | ||
| func: "gpii.tests.binder.clickSelector", | ||
| args: ["#input-button"] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| name: "Test markup event binding for click on a paragraph with a class", | ||
| type: "test", | ||
| expect: 1, | ||
| sequence: [ | ||
| { | ||
| func: "gpii.tests.binder.clickSelector", | ||
| args: [".parapgraph-click"] | ||
sgithens marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }] | ||
| }); | ||
|
|
||
| fluid.defaults("gpii.tests.binder.commonEventBindings.environment", { | ||
| gradeNames: ["gpii.tests.binder.environment"], | ||
| markupFixture: ".viewport-common-event-bindings", | ||
| binderGradeNames: ["gpii.tests.binder.commonEventBindings"], | ||
| moduleName: "Testing common event bindings", | ||
| components: { | ||
| commonEventBindingsTests: { | ||
| type: "gpii.tests.binder.commonEventBindings.caseHolder" | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| gpii.tests.binder.commonEventBindings.environment(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it matters less on the browser side (I think?), but for consistency with the rest of the package, this should use |
||
| })(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| <html> | ||
| <head> | ||
| <title>Unit Tests for Binder Module Common Event Bindings button support...</title> | ||
|
|
||
| <!-- Bring in jQuery and other dependencies --> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/lib/jquery/core/js/jquery.js"></script> | ||
|
|
||
| <!-- Bring in fluid dependencies --> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/Fluid.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/FluidDocument.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/FluidDOMUtilities.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/FluidIoC.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/DataBinding.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/FluidView.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/ModelTransformation.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/core/js/ModelTransformationTransforms.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/enhancement/js/ContextAwareness.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/src/framework/enhancement/js/ProgressiveEnhancement.js"></script> | ||
|
|
||
| <script type="text/javascript" src="../../node_modules/infusion/tests/test-core/utils/js/IoCTestUtils.js"></script> | ||
|
|
||
| <!-- QUnit/jqUnit dependencies --> | ||
| <script type="text/javascript" src="../../node_modules/infusion/tests/lib/qunit/js/qunit.js"></script> | ||
| <script src="/testem.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/tests/test-core/jqUnit/js/jqUnit.js"></script> | ||
| <script type="text/javascript" src="../../node_modules/infusion/tests/test-core/jqUnit/js/jqUnit-browser.js"></script> | ||
|
|
||
| <!-- Our test fixtures --> | ||
| <script type="text/javascript" src="./js/tests-fixtures.js"></script> | ||
|
|
||
| <!-- Bring in client library being tested --> | ||
| <script type="text/javascript" src="/coverage/client/coverageSender.js"></script> | ||
| <script type="text/javascript" src="../../src/js/binder.js"></script> | ||
| <script type="text/javascript" src="../../src/js/common-event-bindings.js"></script> | ||
|
|
||
| <link rel="stylesheet" href="../../node_modules/node-jqunit/node_modules/infusion/tests/lib/qunit/css/qunit.css"/> | ||
| </head> | ||
| <body> | ||
| <h1 id="qunit-header">"Common Event Bindings" Component Tests</h1> | ||
| <h2 id="qunit-banner"></h2> | ||
| <div id="qunit-testrunner-toolbar"></div> | ||
| <h2 id="qunit-userAgent"></h2> | ||
| <ol id="qunit-tests"></ol> | ||
|
|
||
| <!-- Test HTML, we have to hide this ourselves. QUnit's styles put it offscreen, which doesn't work for us. --> | ||
| <div class="viewport-common-event-bindings" style="display:none"> | ||
| <form> | ||
| <h3>Common Event Bindings...</h3> | ||
| <input type="button" id="input-button" value="First Input Button" /> | ||
|
|
||
| <p class="parapgraph-click">This is a paragraph.</p> | ||
| </form> | ||
| </div> | ||
|
|
||
| <!-- our QUnit tests --> | ||
| <script type="text/javascript" src="./js/jqunit/jqunit-binder-commonEventBindings.js"></script> | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should all be namespaced. I'd also suggest using the "long form" to this shorter notation. That way someone can at least opt out of part of the contract in a derived grade by changing the "funcName" to
fluid.identityor the like.