@Test void testAddClass() { String html = readFile("addClass.html"); String htmlOK = readFile("addClass-ok.html"); Jerry $ = jerry(html).$("p:last").addClass("selected"); assertEquals(htmlOK, actualHtml($)); }
@Test void testEmpty() { String html = readFile("empty.html"); String htmlOK = readFile("empty-ok.html"); Jerry doc = jerry(html); doc.$("p").empty(); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testBefore() { String html = readFile("before.html"); String htmlOK = readFile("before-ok.html"); Jerry doc = jerry(html); doc.$("p").before("<b>Hello</b>"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testUnwrap() { String html = readFile("unwrap.html"); String htmlOK = readFile("unwrap-ok.html"); Jerry doc = jerry(html); doc.$("p").unwrap(); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testPseudoHas() { String html = readFile("pseudoHas.html"); String htmlOK = readFile("pseudoHas-ok.html"); Jerry doc = jerry(html); doc.$("div:has(p)").addClass("test"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testPseudoContains2() { String html = readFile("pseudoContains.html"); String htmlOK = readFile("pseudoContains-ok.html"); Jerry doc = jerry(html); doc.$("div:contains(John)").css("text-decoration", "underline"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testAfter() { String html = readFile("after.html"); String htmlOK = readFile("after-ok.html"); Jerry doc = jerry(html); doc.$("p").after("<b>what is the question?</b>"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testHtml4() { String html = readFile("html4.html"); String htmlOK = readFile("html4-ok.html"); Jerry doc = jerry(html); doc.$("div").html("<span class='red'>Hello <b>Again</b></span>"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testFilter4() { String html = readFile("filter4.html"); String htmlOK = readFile("filter4-ok.html"); Jerry doc = jerry(html); doc.$("div").css("background", "#b4b0da") .filter(($this, index) -> index == 1 || $this.attr("id").equals("fourth")) .css("border", "3px double red"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testFirst() { String html = readFile("first.html"); String htmlOK = readFile("first-ok.html"); Jerry $ = jerry(html).$("p span").first().addClass("highlight"); assertEquals(htmlOK, actualHtml($)); }
@Test void testLast() { String html = readFile("last.html"); String htmlOK = readFile("last-ok.html"); Jerry $ = jerry(html).$("p span").last().addClass("highlight"); assertEquals(htmlOK, actualHtml($)); }
@Test void testHtml2() { String html = readFile("html2.html"); String htmlOK = readFile("html2-ok.html"); Jerry doc = jerry(html); Jerry p = doc.$("p:first"); String htmlContent = p.html(); p.text(htmlContent); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testNext() { String html = readFile("next.html"); String htmlOK = readFile("next-ok.html"); Jerry doc = jerry(html); doc.$("button[disabled]").next().text("this button is disabled"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testFilter3() { String html = readFile("filter3.html"); String htmlOK = readFile("filter3-ok.html"); Jerry doc = jerry(html); doc.$("div").css("background", "#c8ebcc") .filter(".middle") .css("border-color", "red"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testEnd() { String html = readFile("end.html"); String htmlOK = readFile("end-ok.html"); Jerry $ = jerry(html).$("p").find("span").end().css("border", "2px red solid"); assertEquals(htmlOK, actualHtml($)); }
@Test void testIs3() { String html = readFile("is3.html"); String htmlOK = readFile("is3-ok.html"); Jerry doc = jerry(html); boolean isFormParent = doc.$("input[type='checkbox']").parent().is("form"); doc.$("div").text("isFormParent = " + isFormParent); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testEq() { String html = readFile("eq.html"); String htmlOK = readFile("eq-ok.html"); Jerry doc = jerry(html); doc.$("li").eq(1).css("background-color", "red"); doc.$("li").eq(-1).css("background-color", "red"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testPrevNextAll() { String html = readFile("prevNextAll.html"); String htmlOK = readFile("prevNextAll-ok.html"); Jerry doc = jerry(html); doc.$(".prev :last-child").prevAll().remove(); doc.$(".next :first-child").nextAll().remove(); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testPseudoButton() { String html = readFile("pseudoButton.html"); String htmlOK = readFile("pseudoButton-ok.html"); Jerry doc = jerry(html); Jerry input = doc.$(":button").css("background", "yellow", "border", "3px red solid"); doc.$("div").text("For this type jQuery found " + input.length() + ".").css("color", "red"); assertEquals(htmlOK, actualHtml(doc)); }
@Test void testPseudoCheckbox() { String html = readFile("pseudoCheckbox.html"); String htmlOK = readFile("pseudoCheckbox-ok.html"); Jerry doc = jerry(html); Jerry input = doc.$("form input:checkbox").wrap("<span></span>").parent().css("background", "yellow", "border", "3px red solid"); doc.$("div").text("For this type jQuery found " + input.length() + ".").css("color", "red"); assertEquals(htmlOK, actualHtml(doc)); }