Skip to content

Commit

Permalink
Make tests cross-plat friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercn committed Jun 14, 2024
1 parent e778b77 commit 849e896
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Components/Endpoints/test/Assets/ImportMapDefinitionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace Microsoft.AspNetCore.Components.Endpoints.Assets;
Expand All @@ -21,7 +22,7 @@ public void CanCreate_Basic_ImportMapDefinition()
"jquery": "https://cdn.example.com/jquery.js"
}
}
""";
""".Replace("\r\n", "\n");

var importMapDefinition = new ImportMapDefinition(
new Dictionary<string, string>
Expand All @@ -33,7 +34,7 @@ public void CanCreate_Basic_ImportMapDefinition()
);

// Assert
Assert.Equal(expectedJson, importMapDefinition.ToJson());
Assert.Equal(expectedJson, importMapDefinition.ToJson().Replace("\r\n", "\n"));
}

[Fact]
Expand All @@ -48,7 +49,7 @@ public void CanCreate_Scoped_ImportMapDefinition()
}
}
}
""";
""".Replace("\r\n", "\n");

var importMapDefinition = new ImportMapDefinition(
null,
Expand All @@ -62,7 +63,7 @@ public void CanCreate_Scoped_ImportMapDefinition()
null);

// Assert
Assert.Equal(expectedJson, importMapDefinition.ToJson());
Assert.Equal(expectedJson, importMapDefinition.ToJson().Replace("\r\n", "\n"));
}

[Fact]
Expand All @@ -78,7 +79,7 @@ public void CanCreate_ImportMap_WithIntegrity()
"https://cdn.example.com/jquery.js": "sha384-abc123"
}
}
""";
""".Replace("\r\n", "\n");

var importMapDefinition = new ImportMapDefinition(
new Dictionary<string, string>
Expand All @@ -92,7 +93,7 @@ public void CanCreate_ImportMap_WithIntegrity()
});

// Assert
Assert.Equal(expectedJson, importMapDefinition.ToJson());
Assert.Equal(expectedJson, importMapDefinition.ToJson().Replace("\r\n", "\n"));
}

[Fact]
Expand All @@ -118,13 +119,13 @@ public void CanBuildImportMap_FromResourceCollection()
"jquery.fingerprint.js": "sha384-abc123"
}
}
""";
""".Replace("\r\n", "\n");

// Act
var importMapDefinition = ImportMapDefinition.FromResourceCollection(resourceAssetCollection);

// Assert
Assert.Equal(expectedJson, importMapDefinition.ToJson());
Assert.Equal(expectedJson, importMapDefinition.ToJson().Replace("\r\n", "\n"));
}

[Fact]
Expand Down Expand Up @@ -189,12 +190,12 @@ public void CanCombine_ImportMaps()
"https://cdn.example.com/react.js": "sha384-def456"
}
}
""";
""".Replace("\r\n", "\n");

// Act
var combinedImportMap = ImportMapDefinition.Combine(firstImportMap, secondImportMap);

// Assert
Assert.Equal(expectedImportMap, combinedImportMap.ToJson());
Assert.Equal(expectedImportMap, combinedImportMap.ToJson().Replace("\r\n", "\n"));
}
}

0 comments on commit 849e896

Please sign in to comment.