Created
October 4, 2024 16:27
-
-
Save mushfiqweb/9a1b62a943027e253b50e990c0ba5813 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Intact.DynamicRendering.Uncork.Components; | |
using Snapshooter.Xunit; | |
namespace Intact.DynamicRendering.UnitTests.Unqork.Components | |
{ | |
public class PhoneNumberTests | |
{ | |
[Fact] | |
public void CreateComponent_ShouldCreatePhoneNumberComponentCorrectly() | |
{ | |
// Arrange | |
var intactComponent = new IntactComponent | |
{ | |
ObjectName = "TestPhoneNumber", | |
Label = "Test Phone Number", | |
Hidden = false, | |
Required = true, | |
ReadOnly = true, | |
RequiredMessage = "Phone number is required" | |
}; | |
// Act | |
var result = PhoneNumber.CreateComponent(intactComponent); | |
// Assert | |
Assert.NotNull(result); | |
Assert.IsType<PhoneNumber>(result); | |
Assert.Equal("phonenumber-v2", result.Type); | |
Assert.Equal("testPhoneNumber", result.Key); | |
Assert.Equal("Test Phone Number", result.Label); | |
Assert.False(result.Hidden); | |
Assert.True(result.Validate.Required); | |
Assert.True(result.ReadOnlyView); | |
Assert.NotNull(result.Errors); | |
Assert.Equal("Phone number is required", result.Errors.Required); | |
// PhoneNumber specific properties | |
Assert.False(result.HideCountry); | |
Assert.Equal("US", result.SelectedCountry); | |
Assert.True(result.ValidatePhoneNumber); | |
Assert.Equal(0, result.PhoneType); | |
// Snapshot testing | |
Snapshot.Match(intactComponent, "InitialComponentPhoneNumber"); | |
Snapshot.Match(result, "CreatedComponentPhoneNumber"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment