public static void MergeClassAttribute_adds_attribute(string value) { // Arrange var attributes = new Dictionary <string, string>(); // Act VueHtmlAttributeHelper.MergeClassAttribute(attributes, value); // Assert attributes.Keys.FirstOrDefault().ShouldBe("v-bind:class"); attributes.Values.FirstOrDefault().ShouldBe(value); }
public static void MergeVeeValidateAttributes_adds_attribute() { // Arrange var attributes = new Dictionary <string, string>(); // Act VueHtmlAttributeHelper.MergeVeeValidateAttribute(attributes, "email", "true"); VueHtmlAttributeHelper.MergeVeeValidateAttribute(attributes, "required", "true"); // Assert attributes.Keys.FirstOrDefault().ShouldBe("v-validate"); attributes.Values.FirstOrDefault().ShouldBe("{email:true,required:true}"); }
public static void MergeVeeValidateAttributes_throws_when_validation_rules_in_string_format() { // Arrange var attributes = new Dictionary <string, string> { { "v-validate", "'required|email'" } }; // Act // Assert Should.Throw <Exception>(() => VueHtmlAttributeHelper.MergeVeeValidateAttribute(attributes, "credit_card", "true")); }
public static void MergeVeeValidateAttributes_concatenates_existing_rules() { // Arrange var attributes = new Dictionary <string, string> { { "v-validate", "{required:true}" } }; // Act VueHtmlAttributeHelper.MergeVeeValidateAttribute(attributes, "email", "true"); // Assert attributes.Keys.FirstOrDefault().ShouldBe("v-validate"); attributes.Values.FirstOrDefault().ShouldBe("{required:true,email:true}"); }
public static void MergeClassAttribute_preserves_existing_attribute_name(string attributeName) { // Arrange var attributes = new Dictionary <string, string> { { attributeName, "classObject" } }; // Act VueHtmlAttributeHelper.MergeClassAttribute(attributes, "anotherClassObject"); // Assert attributes.Keys.FirstOrDefault().ShouldBe(attributeName); attributes.Values.FirstOrDefault().ShouldBe("[classObject,anotherClassObject]"); }
public static void MergeClassAttribute_concatenates_existing_attributes(string existingValue) { // Arrange var attributes = new Dictionary <string, string> { { ":class", existingValue } }; // Act VueHtmlAttributeHelper.MergeClassAttribute(attributes, "anotherClassObject"); // Assert attributes.Keys.FirstOrDefault().ShouldBe(":class"); attributes.Values.FirstOrDefault().ShouldBe($"[{existingValue.TrimStart('[').TrimEnd(']')},anotherClassObject]"); }
public static void MergeVeeValidateAttributes_preserves_any_modifiers() { // Arrange var attributes = new Dictionary <string, string> { { "v-validate.continue", "" } }; // Act VueHtmlAttributeHelper.MergeVeeValidateAttribute(attributes, "email", "true"); VueHtmlAttributeHelper.MergeVeeValidateAttribute(attributes, "required", "true"); // Assert attributes.Keys.FirstOrDefault().ShouldBe("v-validate.continue"); attributes.Values.FirstOrDefault().ShouldBe("{email:true,required:true}"); }
public static ClientModelValidationContext AddValidationRule(this ClientModelValidationContext context, string ruleName, string value) { VueHtmlAttributeHelper.MergeVeeValidateAttribute(context.Attributes, ruleName, value.ToString()); return(context); }