diff --git a/src/framework/core/js/ModelTransformation.js b/src/framework/core/js/ModelTransformation.js index 4786a4eb31..ed735f9ea8 100644 --- a/src/framework/core/js/ModelTransformation.js +++ b/src/framework/core/js/ModelTransformation.js @@ -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; @@ -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) { diff --git a/tests/framework-tests/core/js/ModelTransformationTests.js b/tests/framework-tests/core/js/ModelTransformationTests.js index a682ad9dec..78d97a4bcd 100644 --- a/tests/framework-tests/core/js/ModelTransformationTests.js +++ b/tests/framework-tests/core/js/ModelTransformationTests.js @@ -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: { @@ -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, @@ -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, @@ -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", @@ -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", @@ -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,