Thanks for these improvements, anastasia -
i) the actual fix could still see some redundancy removed. Consider an
implementation of the form beginning
fluid.each(["success", "error"], function (callbackName) { .....
ii) there are unnecessary calls to "makeCallbackFunction" in the tests as well as unnecessary expression of
the arguments - also the fluid.tests namespace whilst used only in tests will still eventually be subject to
congestion. Could you supply more meaningful names to "testSuccessFunction", "callbackFilenames" etc? Or
even remove them entirely by the same consideration applied in i).
A suitable way of expressing the tests might be as follows:
..... () {
var filenames = {
success: "Caching-test.html",
error: "Foofer.doodle"
};
var successCases = [{
name: "No success callback",
callback: null},{
name: "Literal success callback",
callback: fluid.tests.testSuccessFunction},{
name: "Named success callback",
callback: "fluid.tests.testSuccessFunction"]
}];
var errorCases = [{
name: "No error callback",
callback: null},{
name: "Literal error callback",
callback: fluid.tests.testErrorFunction},{
name: "Named error callback",
callback: "fluid.tests.testErrorFunction"
}];
fluid.each(successCases, function(scase), {
fluid.each(errorCases, function(ecase), {
fluid.tests.testFetchResourcesCallbacks("FLUID-4576: fetchResources
callback with " +
scase.name + " and " + ecase.name, filenames, scase.callback,
ecase.callback);
})
});
This would succeed in testing a lot more of the implementation surface with smaller and more readable test
case bulk. You can see examples of this kind of "structure-driven test case" for example in our Uploader
tests at
https://github.com/fluid-project/infusion/blob/master/src/webapp/tests/component-tests/uploader/js/UploaderTests.js#L435-572
JavaScript is a great environment for writing test cases!
Thanks,
Antranig
On 23/01/2012 12:02, Anastasia Cheetham wrote:
@amb26, I've added support for the "error" callback and refactored the tests to
remove code duplication. Please have a look, and let me know what else I can do to
improve things.
---
Reply to this email directly or view it on GitHub:
https://github.com/fluid-project/infusion/pull/197#issuecomment-3619567
_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://lists.idrc.ocad.ca/mailman/listinfo/fluid-work