Exemplo n.º 1
0
        public void JavaScriptInstantiation(MDCTextFieldStyle variant, string id)
        {
            AddComponent(
                ("Id", id),
                ("Variant", variant));

            FakeComponent.FindComponentById(id).ShouldNotBeNull();
        }
Exemplo n.º 2
0
        public void Value_IsRendered(MDCTextFieldStyle variant, string value)
        {
            var textField = AddComponent(
                ("Value", value),
                ("Variant", variant));

            textField.ShouldHaveInputNode().Attributes["value"].Value.ShouldBe(value);
        }
Exemplo n.º 3
0
        public void GivenTextFieldIsPreFilled_WhenFirstRendered_ThenLabelFloatsAbove(MDCTextFieldStyle variant, string label, string value)
        {
            var sut = AddComponent(
                ("Variant", variant),
                ("Label", label),
                ("Value", value));

            sut.ShouldHaveLabelNode(variant).ShouldContainCssClasses("mdc-floating-label", "mdc-floating-label--float-above");
        }
Exemplo n.º 4
0
        public void Label_IsRendered(MDCTextFieldStyle variant, string label)
        {
            var sut = AddComponent(
                ("Variant", variant),
                ("Label", label));

            var labelNode = sut.ShouldHaveLabelNode(variant);

            labelNode.ChildNodes.ShouldHaveSingleItem().InnerText.ShouldBe(label);
        }
Exemplo n.º 5
0
        public void Label_IsLinkedToInputElement_AndDoNotClashWithOtherInstances(MDCTextFieldStyle variant)
        {
            var textField1 = AddComponent(("Variant", variant));
            var textField2 = AddComponent(("Variant", variant));

            var id1 = textField1.ShouldHaveInputNode().Attributes["id"];
            var id2 = textField2.ShouldHaveInputNode().Attributes["id"];

            id1.Value.ShouldNotBe(id2.Value);
        }
Exemplo n.º 6
0
        public void Disabled(MDCTextFieldStyle variant)
        {
            var sut = AddComponent(
                ("Variant", variant),
                ("Disabled", true));

            var rootNode = sut.GetDocumentNode();

            var labelElement = rootNode.SelectNodes("/label").ShouldHaveSingleItem();

            labelElement.Attributes["class"].Value.Split(" ").ShouldContain("mdc-text-field--disabled");

            var inputElement = rootNode.SelectNodes("/label/input").ShouldHaveSingleItem();

            inputElement.Attributes["disabled"].ShouldNotBeNull();
        }
Exemplo n.º 7
0
        public async Task Value_DataBind(MDCTextFieldStyle variant, string value)
        {
            var spy = new ValueSpy <string>();

            var sut = AddComponent(
                ("Variant", variant),
                ("ValueChanged", EventCallback.Factory.Create <string>(this, spy.SetValue)));

            var inputNode = sut.ShouldHaveInputNode();

            inputNode.Attributes["value"].ShouldBeNull();

            await inputNode.InputAsync(value);

            sut.ShouldHaveInputNode().Attributes["value"].Value.ShouldBe(value);
            spy.Value.ShouldBe(value);
        }
Exemplo n.º 8
0
        public void InputElement_HasAriaLabelledByAttribute(MDCTextFieldStyle variant)
        {
            var sut = AddComponent(("Variant", variant));

            var inputElement = sut.ShouldHaveInputNode();
            var inputId      = inputElement.Attributes["aria-labelledby"];

            inputId.ShouldNotBeNull();
            inputId.Value.ShouldNotBeNullOrEmpty();

            var labelElement   = sut.ShouldHaveLabelNode(variant);
            var labelElementId = labelElement.Attributes["id"];

            labelElementId.ShouldNotBeNull();
            labelElementId.Value.ShouldNotBeNullOrWhiteSpace();

            inputId.Value.ShouldBe(labelElementId.Value);
        }
Exemplo n.º 9
0
        public static HtmlNode ShouldHaveLabelNode(this RenderedComponent <MDCTextField> source, MDCTextFieldStyle variant)
        {
            var root = source.GetDocumentNode();

            HtmlNode labelNode = null;

            switch (variant)
            {
            case MDCTextFieldStyle.Filled:
                labelNode = root.SelectNodes("//label/span[2]").ShouldHaveSingleItem();
                break;

            case MDCTextFieldStyle.Outlined:
                labelNode = root.SelectNodes("//label/span/span/span").ShouldHaveSingleItem();
                break;
            }

            labelNode.ShouldNotBeNull();
            return(labelNode);
        }