Skip to content

Commit

Permalink
test: add 3 test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit Patel committed Nov 3, 2023
1 parent 45d327f commit 3844773
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/java/org/jsoup/helper/HttpConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,14 @@ public void caseInsensitiveHeaders(Locale locale) {
String actual = connect.request().header("Key");
assertEquals(value, actual);
}

@Test void testHeadersMethod(){
Connection.Request req = new HttpConnection.Request();
req.addHeader("Accept", "Something");
req.addHeader("Foo", "Bar");

Map<String, String> headerMap = req.headers();
assertEquals("Something", headerMap.get("Accept"));
assertEquals("Bar", headerMap.get("Foo"));
}
}
21 changes: 21 additions & 0 deletions src/test/java/org/jsoup/nodes/AttributeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,25 @@ public void html() {
Document doc2 = Jsoup.parse(html, Parser.htmlParser().settings(ParseSettings.preserveCase));
assertEquals("<a href=\"autofocus\" REQUIRED>One</a>", doc2.selectFirst("a").outerHtml());
}

@Test
public void testEquals() {
Attributes attributes = new Attributes();
Attribute attribute = new Attribute("name", "value", attributes);
Attribute sameAttribute = new Attribute("name", "value", attributes);
Attribute differentAttribute = new Attribute("newName", "value", attributes);

assertTrue(attribute.equals(sameAttribute));
assertFalse(attribute.equals(differentAttribute));
}

@Test
public void testClone() {
Attributes attributes = new Attributes();
Attribute attribute = new Attribute("name", "value", attributes);
Attribute clonedAttribute = attribute.clone();
assertEquals(attribute.getKey(), clonedAttribute.getKey());
assertEquals(attribute.getValue(), clonedAttribute.getValue());
}

}

0 comments on commit 3844773

Please sign in to comment.