<commit_before>import XCTest
@testable import Aztec


// MARK: - UnsupportedHTMLTests
//
class UnsupportedHTMLTests: XCTestCase {

    /// Verifies that a UnsupportedHTML Instance can get properly serialized back and forth
    ///
    func testSnippetsGetProperlyEncodedAndDecoded() {
        let unsupported = UnsupportedHTML()
        unsupported.append(element: sampleElement)
        unsupported.append(element: sampleElement)

        let data = NSKeyedArchiver.archivedData(withRootObject: unsupported)
        guard let restored = NSKeyedUnarchiver.unarchiveObject(with: data) as? UnsupportedHTML else {
            XCTFail()
            return
        }

        let elements = restored.elements
        XCTAssert(elements.count == 2)

        for element in elements {
            XCTAssert(element.children == sampleChildren)
            XCTAssert(element.attributes == sampleAttributes)
        }
    }
}


// MARK: - Helpers
//
private extension UnsupportedHTMLTests {
    var sampleCSS: CSSProperty {
        return CSSProperty(name: "text", value: "bold")
    }

    var sampleAttributes: [Attribute] {
        return [
            Attribute(name: "none", value: .none),
            Attribute(name: "string", value: .string("value")),
            Attribute(name: "style", value: .inlineCss([self.sampleCSS]))
        ]
    }

    var sampleChildren: [Node] {
        return [
            TextNode(text: "Some Text"),
            CommentNode(text: "Some Comment"),
        ]
    }

    var sampleElement: ElementNode {
        return ElementNode(name: "Test", attributes: self.sampleAttributes, children: self.sampleChildren)
    }
}<commit_msg>UnsupportedHTMLTests: Updates Tests<commit_after>import XCTest
@testable import Aztec


// MARK: - UnsupportedHTMLTests
//
class UnsupportedHTMLTests: XCTestCase {

    /// Verifies that a UnsupportedHTML Instance can get properly serialized back and forth
    ///
    func testSnippetsGetProperlyEncodedAndDecoded() {
        let unsupported = UnsupportedHTML(representations: [sampleRepresentation, sampleRepresentation])

        let data = NSKeyedArchiver.archivedData(withRootObject: unsupported)
        guard let restored = NSKeyedUnarchiver.unarchiveObject(with: data) as? UnsupportedHTML else {
            XCTFail()
            return
        }

        XCTAssert(restored.representations.count == 2)

        for representation in restored.representations {
            XCTAssert(representation == sampleRepresentation)
        }
    }
}


// MARK: - Helpers
//
private extension UnsupportedHTMLTests {
    var sampleCSS: CSSProperty {
        return CSSProperty(name: "text", value: "bold")
    }

    var sampleAttributes: [Attribute] {
        return [
            Attribute(name: "none", value: .none),
            Attribute(name: "string", value: .string("value")),
            Attribute(name: "style", value: .inlineCss([self.sampleCSS]))
        ]
    }

    var sampleChildren: [Node] {
        return [
            TextNode(text: "Some Text"),
            CommentNode(text: "Some Comment"),
        ]
    }

    var sampleElement: ElementNode {
        return ElementNode(name: "Test", attributes: self.sampleAttributes, children: self.sampleChildren)
    }

    var sampleRepresentation: HTMLElementRepresentation {
        return HTMLElementRepresentation(self.sampleElement)
    }
}
{'fraction_non_alphanumeric': 0.096045197740113, 'fraction_numerical': 0.0005947071067499256, 'mean_word_length': 2.6724890829694323, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6710426', 'n_tokens_mistral': 918, 'n_tokens_neox': 884, 'n_words': 214}