mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +02:00
feat: Blazor tests added
This commit is contained in:
1 parent
b4378b643b
commit
c60f622989
7 files changed
+309
-21
No files matched your search
@@ -0,0 +1,53 @@
|
||||
using System.Threading;
|
||||
using Bunit;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using WotBlitzStatisticsPro.Blazor.Messages;
|
||||
using WotBlitzStatisticsPro.Blazor.Shared;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Blazor.Tests.Pages
|
||||
{
|
||||
public class MainLayoutTest: TestContextBase
|
||||
{
|
||||
private IRenderedComponent<MainLayout> _component;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_component = TestContext?.RenderComponent<MainLayout>();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShouldFireMediatorEventEachTimeWhenLanguageChanged()
|
||||
{
|
||||
// =====================================
|
||||
// Hint for css selector
|
||||
/*
|
||||
By.css('.classname') // get by class name
|
||||
By.css('input[type=radio]') // get input by type radio
|
||||
By.css('.parent .child') // get child who has a parent
|
||||
*/
|
||||
|
||||
// Take a look at the component text
|
||||
// var html = _component.Markup;
|
||||
|
||||
// =====================================
|
||||
|
||||
// All 3 languages in a RadzenSplitButton
|
||||
var elements = _component.FindAll(".rz-menuitem");
|
||||
|
||||
elements.Should().NotBeNull();
|
||||
elements.Count.Should().Be(3);
|
||||
|
||||
string[] expectedLanguages = {"en-US", "ru-RU", "de-DE"};
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
elements[i].Click();
|
||||
MediatorMock.Verify(m => m.Publish(
|
||||
It.Is<ChangeCurrentCultureMessage>(m => m.CultureName == expectedLanguages[0]),
|
||||
It.IsAny<CancellationToken>()), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user