Closer/iphone/CloserTests/CryptoTests/RecoveryKeyManagerTests.swift

25 lines
916 B
Swift
Raw Normal View History

import XCTest
@testable import Closer
final class RecoveryKeyManagerTests: XCTestCase {
func testGeneratePhraseIsWellFormed() throws {
let phrase = try RecoveryKeyManager.generatePhrase()
let parts = phrase.split(separator: " ")
XCTAssertEqual(parts.count, RecoveryKeyManager.phraseWordCount)
XCTAssertTrue(try RecoveryKeyManager.isWellFormed(phrase))
}
func testNormalizeCollapsesWhitespaceAndLowercases() throws {
let messy = " ABLE acid ACRE "
let normalized = RecoveryKeyManager.normalize(messy)
XCTAssertEqual(normalized, "able acid acre")
}
func testMalformedPhrasesRejected() throws {
// Too short.
XCTAssertFalse(try RecoveryKeyManager.isWellFormed("able acid"))
// Unknown word.
XCTAssertFalse(try RecoveryKeyManager.isWellFormed("able acid acre aged aide also army atom baby xxx"))
}
}