public void UniteMapElementsForSingleScript() { var firstMap = new RequireMapElement { For = "scriptA", Replacements = new List <RequireReplacement> { new RequireReplacement { OldKey = "jquery", NewKey = "jquery.min" } } }; var secondMap = new RequireMapElement { For = "scriptA", Replacements = new List <RequireReplacement> { new RequireReplacement { OldKey = "amplify", NewKey = "amplify.min" } } }; var firstCollection = ConfigurationCreators.CreateCollectionWithMaps(firstMap); var secondCollection = ConfigurationCreators.CreateCollectionWithMaps(secondMap); var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection); var merged = merger.GetMerged(); var expectedCollection = ConfigurationCreators.CreateEmptyCollection(); expectedCollection.Map.MapElements.Add(new RequireMapElement { For = "scriptA", Replacements = new List <RequireReplacement> { new RequireReplacement { OldKey = "jquery", NewKey = "jquery.min" }, new RequireReplacement { OldKey = "amplify", NewKey = "amplify.min" } } }); CustomAssert.JsonEquals(expectedCollection, merged); }
public void ReadMap() { var config = ReadJson(new TestFileReader()); var map = new RequireMapElement { For = "controllers/root/home/complexLoad", Replacements = new List <RequireReplacement> { new RequireReplacement { OldKey = "req1", NewKey = "req2" } } }; var expected = ConfigurationCreators.CreateCollectionWithMaps(map); CustomAssert.JsonEquals(expected, config); }
public void CreateSingleMapListForDifferentScripts() { var scriptAMap = new RequireMapElement { For = "scriptA", Replacements = new List <RequireReplacement> { new RequireReplacement { OldKey = "jquery", NewKey = "jquery.min" } } }; var scriptBMap = new RequireMapElement { For = "scriptB", Replacements = new List <RequireReplacement> { new RequireReplacement { OldKey = "jquery", NewKey = "jquery.custom" } } }; var firstCollection = ConfigurationCreators.CreateCollectionWithMaps(scriptAMap); var secondCollection = ConfigurationCreators.CreateCollectionWithMaps(scriptBMap); var merger = ConfigurationCreators.CreateDefaultConfigMerger(firstCollection, secondCollection); var merged = merger.GetMerged(); var expectedCollection = ConfigurationCreators.CreateEmptyCollection(); expectedCollection.Map.MapElements.Add(scriptAMap); expectedCollection.Map.MapElements.Add(scriptBMap); CustomAssert.JsonEquals(expectedCollection, merged); }