public void SerializesPackagesInRequireJSFormat() { var expected = "var require = {\"baseUrl\":\"\",\"locale\":\"en\",\"urlArgs\":null,\"waitSeconds\":7,\"paths\":{},\"packages\":[{\"name\":\"cart\",\"main\":\"main\"},{\"name\":\"store\",\"main\":\"store\"}],\"shim\":{},\"map\":{}};"; var config = new RequireRendererConfiguration(); var collection = ConfigurationCreators.CreateCollectionWithPackages( new RequirePackage("cart", "main"), new RequirePackage("store", "store") ); var outputConfig = RequireJsHtmlHelpers.createOutputConfigFrom(collection, config, "en"); var actual = Helpers.JavaScriptHelpers.SerializeAsVariable(outputConfig, "require"); Assert.Equal(expected, actual); }
public void ReadPackagesArray() { var expectedPackages = new[] { new RequirePackage("cart", "main"), new RequirePackage("store", "store") }; var expectedCollection = ConfigurationCreators.CreateCollectionWithPackages(expectedPackages); var config = ReadJson(new TestFileReader()); Assert.Equal(2, config.Packages.PackageList.Count); CustomAssert.JsonEquals(expectedCollection, config); }
public void ReplacePackagesWithSameName() { var packageA1 = new RequirePackage("a", "main"); var packageA2 = new RequirePackage("a", "start", "/somewhere"); var firstConfig = ConfigurationCreators.CreateCollectionWithPackages(packageA1); var secondConfig = ConfigurationCreators.CreateCollectionWithPackages(packageA2); var merger = ConfigurationCreators.CreateBundleProcessingConfigMerger(firstConfig, secondConfig); var merged = merger.GetMerged(); var expected = ConfigurationCreators.CreateEmptyCollection(); expected.Packages.PackageList = new List <RequirePackage> { new RequirePackage("a", "start", "/somewhere") }; CustomAssert.JsonEquals(expected, merged); }