Skip to content

Commit 7b09a07

Browse files
committed
Update tests
1 parent d0d4403 commit 7b09a07

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

test/Microsoft.NET.Sdk.Razor.Tests/ScopedCssIntegrationTests.cs

+21-4
Original file line numberDiff line numberDiff line change
@@ -410,15 +410,32 @@ public void RegeneratingScopedCss_ForProject()
410410

411411
// Make an edit
412412
var scopedCssFile = Path.Combine(ProjectDirectory.TestRoot, "Components", "Pages", "Index.razor.css");
413-
File.WriteAllLines(scopedCssFile, File.ReadAllLines(scopedCssFile).Concat(new[] { "body { background-color: orangered; }" }));
413+
File.WriteAllLines(scopedCssFile, File.ReadAllLines(scopedCssFile).Concat(["body { background-color: orangered; }"]));
414+
415+
build = CreateBuildCommand(ProjectDirectory);
416+
ExecuteCommand(build, "/t:UpdateStaticWebAssetsDesignTime").Should().Pass();
417+
418+
// Verify the generated file contains newly added css
419+
AssertFileContains(bundlePath, "background-color: orangered");
420+
421+
// Verify that CSS edits continue to apply after new JS modules are added to the project
422+
// https://github.com/dotnet/aspnetcore/issues/57599
423+
var collocatedJsFile = Path.Combine(ProjectDirectory.TestRoot, "Components", "Pages", "Index.razor.js");
424+
File.WriteAllLines(collocatedJsFile, ["console.log('Hello, world!');"]);
425+
File.WriteAllLines(scopedCssFile, File.ReadAllLines(scopedCssFile).Concat(["h1 { color: purple; }"]));
414426

415427
build = CreateBuildCommand(ProjectDirectory);
416428
ExecuteCommand(build, "/t:UpdateStaticWebAssetsDesignTime").Should().Pass();
417429

418-
var fileInfo = new FileInfo(bundlePath);
419-
fileInfo.Should().Exist();
420430
// Verify the generated file contains newly added css
421-
fileInfo.ReadAllText().Should().Contain("background-color: orangered");
431+
AssertFileContains(bundlePath, "color: purple");
432+
433+
static void AssertFileContains(string fileName, string content)
434+
{
435+
var fileInfo = new FileInfo(fileName);
436+
fileInfo.Should().Exist();
437+
fileInfo.ReadAllText().Should().Contain(content);
438+
}
422439
}
423440
}
424441

0 commit comments

Comments
 (0)