Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/framework/core/js/ModelTransformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,17 @@ var fluid = fluid || fluid_2_0;
if (hw(transformSpec.inputPath)) {
matchPath = fluid.model.composePaths(transform.inputPrefix, transformSpec.inputPath);
}
else if (hw(transform.outputPrefix) || hw(transformSpec.outputPath)) {
matchPath = fluid.model.composePaths(transform.outputPrefix, transformSpec.outputPath);
else if (hw(transform.outputPrefix)) {
matchPath = transform.outputPrefix
}

if (matchPath) {
transform.queuedTransforms.push({transformSpec: transformSpec, outputPrefix: transform.outputPrefix, inputPrefix: transform.inputPrefix, matchPath: matchPath});
transform.queuedTransforms.push({
transformSpec: transformSpec,
outputPrefix: transform.outputPrefix,
inputPrefix: transform.inputPrefix,
matchPath: matchPath
});
return true;
}
return false;
Expand Down Expand Up @@ -383,8 +388,8 @@ var fluid = fluid || fluid_2_0;
var defaults = fluid.defaults(typeName);
return { defaults: defaults, typeName: typeName};
};
// A utility which is helpful in computing inverses involving compound values.

// A utility which is helpful in computing inverses involving compound values.
// For example, with the valueMapper, compound input values are accepted as literals implicitly,
// whereas as output values they must be escaped. This utility escapes a value if it is not primitive.
fluid.model.transform.literaliseValue = function (value) {
Expand Down
113 changes: 107 additions & 6 deletions tests/framework-tests/core/js/ModelTransformationTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
};

jqUnit.module("Model Transformation");

fluid.tests.transforms.wrapTransform = function (transform) {
return {
value: {
Expand Down Expand Up @@ -725,6 +725,107 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
});
});

var wildCardTestsFixtures = [
{
rules: {
"cat.*": {
transform: {
inputPath: "",
outputPath: "test",
type: "value"
}
}
},
expected: {
cat: {
meow: {
test: {
"its": true
}
},
barks: {
test: {
"its": false
}
}
}
}
}, {
rules: {
transform: {
inputPath: "cat.*",
outputPath: "test",
type: "value"
}
},
expected: {
cat: {
meow: {
test: {
"its": true
}
},
barks: {
test: {
"its": false
}
}
}
}
}, {
rules: {
transform: {
inputPath: "cat.*.its",
outputPath: "",
type: "value"
}
},
expected: {
cat: {
meow: {
"its": true
},
barks: {
"its": false
}
}
}
}, {
rules: {
"cat.*": {
transform: {
inputPath: "its",
outputPath: "",
type: "value"
}
}
},
expected: {
cat: {
meow: true,
barks: false
}
}
}
];

jqUnit.test("Transform with wildcard path, input and output Path", function () {
var model = {
cat: {
meow: {
"its": true
},
barks: {
"its": false
}
}
};
fluid.each(wildCardTestsFixtures, function (fixture) {
var result = fluid.model.transformWithRules(model, fixture.rules);
jqUnit.assertDeepEq("bafdsklsadf", fixture.expected, result);
});
});

var arrayValueTests = [{
message: "arrayValue() should box a non-array value up as one.",
transformWrap: true,
Expand Down Expand Up @@ -1184,7 +1285,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
jqUnit.assertDeepEq("Rules transformed to expanded form", expectedRules, expandedRules);
testCompact(" - expanded", expandedRules);
});

fluid.tests.transforms.metadataRules = {
type: "fluid.transforms.valueMapper",
defaultInputValue: true,
Expand All @@ -1206,14 +1307,14 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
]
};

fluid.tests.transforms.inverseMetadataRules =
fluid.model.transform.invertConfiguration({
"": {
transform: fluid.tests.transforms.metadataRules
}
});

fluid.tests.transforms.metadataCases = {
"forward flashing": {
message: "valueMapper selects primitive option 1",
Expand Down Expand Up @@ -1247,7 +1348,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}
};

fluid.tests.transforms.inverseMetadataCases = {
"backward flashing": {
message: "valueMapper inverts to primitive 1",
Expand Down Expand Up @@ -1281,7 +1382,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
}
};

jqUnit.test("valueMapper with compound values - FLUID-5479 metadata editing example", function () {
fluid.tests.transforms.testOneStructure(fluid.tests.transforms.metadataCases, {
transformWrap: true,
Expand Down