Skip to content

Instantly share code, notes, and snippets.

@amb26
Created September 26, 2013 19:14
Show Gist options
  • Save amb26/6719134 to your computer and use it in GitHub Desktop.
Save amb26/6719134 to your computer and use it in GitHub Desktop.
Very basic FLUID-3674 model relay test
fluid.defaults("fluid.tests.changer", {
gradeNames: ["fluid.littleComponent", "autoInit"],
invokers: {
change: {
changePath: "{arguments}.0",
value: "{arguments.1"
}
}
});
fluid.defaults("fluid.tests.fluid3674head", {
gradeNames: ["fluid.standardRelayComponent", "fluid.tests.changer", "fluid.tests.changeRecorder", "autoInit"],
model: { // test forward reference as well as transactional initialisation
innerModel: "{child}.model.nested1"
},
modelListeners: {
"innerModel": "{that}.record({change}.path, {change}.value, {change}.oldValue)"
},
components: {
child: {
type: "fluid.tests.changer",
options: {
gradeNames: ["fluid.standardRelayComponent"],
model: {
nested1: {
nested2: "thing"
}
}
}
}
}
});
jqUnit.test("FLUID-3674 basic model relay test", function () {
var that = fluid.tests.fluid3674head();
var expected = {
innerModel: {
nested2: "thing"
}
};
jqUnit.assertDeepEq("Model successfully resolved on init", expected, that.model);
var expected2 = [{
path: ["innerModel"], oldValue: undefined, value: {nested2: "thing"}
}];
jqUnit.assertDeepEq("Registered initial change", expected2, that.fireRecord);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment