2020-01-29 08:28:37 +01:00
|
|
|
//
|
|
|
|
// FeedlyTextSanitizationTests.swift
|
|
|
|
// AccountTests
|
|
|
|
//
|
|
|
|
// Created by Kiel Gillard on 29/1/20.
|
|
|
|
// Copyright © 2020 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
2024-05-16 17:28:36 +02:00
|
|
|
@testable import Feedly
|
|
|
|
|
|
|
|
final class FeedlyTextSanitizationTests: XCTestCase {
|
2020-01-29 08:28:37 +01:00
|
|
|
|
|
|
|
func testRTLSanitization() {
|
|
|
|
|
|
|
|
let targetsAndExpectations: [(target: String?, expectation: String?)] = [
|
|
|
|
(nil, nil),
|
|
|
|
("", ""),
|
|
|
|
(" ", " "),
|
|
|
|
("text", "text"),
|
|
|
|
("<div style=\"direction:rtl;text-align:right\">", "<div style=\"direction:rtl;text-align:right\">"),
|
|
|
|
("</div>", "</div>"),
|
|
|
|
("<div style=\"direction:rtl;text-align:right\">text", "<div style=\"direction:rtl;text-align:right\">text"),
|
|
|
|
("text</div>", "text</div>"),
|
|
|
|
("<div style=\"direction:rtl;text-align:right\"></div>", ""),
|
|
|
|
("<DIV style=\"direction:rtl;text-align:right\"></div>", "<DIV style=\"direction:rtl;text-align:right\"></div>"),
|
|
|
|
("<div style=\"direction:rtl;text-align:right\"></DIV>", "<div style=\"direction:rtl;text-align:right\"></DIV>"),
|
|
|
|
("<div style=\"direction:rtl;text-align:right\">text</div>", "text"),
|
|
|
|
]
|
|
|
|
|
|
|
|
let sanitizer = FeedlyRTLTextSanitizer()
|
|
|
|
|
|
|
|
for (target, expectation) in targetsAndExpectations {
|
|
|
|
let calculated = sanitizer.sanitize(target)
|
|
|
|
XCTAssertEqual(expectation, calculated)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|