This commit is contained in:
Nabil Chatbi 2017-03-17 23:16:53 +01:00
parent 040d27c5c0
commit d7f6440c15
2 changed files with 35 additions and 2 deletions

View File

@ -22,11 +22,29 @@ class AttributeTest: XCTestCase {
XCTAssertEqual(s + "=\"A" + s + "B\"", attr.html())
XCTAssertEqual(attr.html(), attr.toString())
}
func testRemoveCaseSensitive()throws {
let a: Attributes = Attributes()
try a.put("Tot", "a&p")
try a.put("tot", "one")
try a.put("Hello", "There")
try a.put("hello", "There")
try a.put("data-name", "Jsoup")
XCTAssertEqual(5, a.size());
try a.remove(key: "Tot");
try a.remove(key: "Hello");
XCTAssertEqual(3, a.size());
XCTAssertTrue(a.hasKey(key: "tot"));
XCTAssertFalse(a.hasKey(key: "Tot"));
}
static var allTests = {
return [
("testHtml", testHtml),
("testWithSupplementaryCharacterInAttributeKeyAndValue", testWithSupplementaryCharacterInAttributeKeyAndValue)
("testWithSupplementaryCharacterInAttributeKeyAndValue", testWithSupplementaryCharacterInAttributeKeyAndValue),
("testRemoveCaseSensitive",testRemoveCaseSensitive)
]
}()

View File

@ -927,6 +927,20 @@ class ElementTest: XCTestCase {
XCTAssertEqual(1, els.size())
XCTAssertEqual("html > body > fb|comments", try els.get(0).cssSelector())
}
func testChainedRemoveAttributes()throws {
let html = "<a one two three four>Text</a>"
let doc = try SwiftSoup.parse(html)
let a: Element = try doc.select("a").first()!
try a.removeAttr("zero")
.removeAttr("one")
.removeAttr("two")
.removeAttr("three")
.removeAttr("four")
.removeAttr("five");
XCTAssertEqual("<a>Text</a>", try a.outerHtml());
}
static var allTests = {
return [
@ -998,7 +1012,8 @@ class ElementTest: XCTestCase {
("testRelativeUrls", testRelativeUrls),
("testAppendMustCorrectlyMoveChildrenInsideOneParentElement", testAppendMustCorrectlyMoveChildrenInsideOneParentElement),
("testHashcodeIsStableWithContentChanges", testHashcodeIsStableWithContentChanges),
("testNamespacedElements", testNamespacedElements)
("testNamespacedElements", testNamespacedElements),
("testChainedRemoveAttributes",testChainedRemoveAttributes)
]
}()
}