Exemplo n.º 1
0
        public void CanRenderFragmentsWhilePreservingSurroundingElements()
        {
            // Initially, the region isn't shown
            var appElement     = MountTestComponent <RenderFragmentToggler>();
            var originalButton = appElement.FindElement(By.TagName("button"));
            Func <IEnumerable <IWebElement> > fragmentElements = () => appElement.FindElements(By.CssSelector("p[name=fragment-element]"));

            Assert.Empty(fragmentElements());

            // The JS-side DOM builder handles regions correctly, placing elements
            // after the region after the corresponding elements
            Assert.Equal("The end", appElement.FindElements(By.CssSelector("div > *:last-child")).Single().Text);

            // When we click the button, the region is shown
            originalButton.Click();
            WaitAssert.Single(fragmentElements);

            // The button itself was preserved, so we can click it again and see the effect
            originalButton.Click();
            WaitAssert.Empty(fragmentElements);
        }