30 lines
862 B
Swift
30 lines
862 B
Swift
import Testing
|
|
@testable import MacSyncShared
|
|
|
|
@Suite("Phone Normalization")
|
|
struct PhoneNormalizationTests {
|
|
|
|
@Test func tenDigitsPrependsPlusOne() {
|
|
#expect(PhoneUtils.normalize("5551234567") == "+15551234567")
|
|
}
|
|
|
|
@Test func elevenDigitsStartingWithOnePrependsPlus() {
|
|
#expect(PhoneUtils.normalize("15551234567") == "+15551234567")
|
|
}
|
|
|
|
@Test func alreadyHasPlusPrefixPreserved() {
|
|
#expect(PhoneUtils.normalize("+15551234567") == "+15551234567")
|
|
}
|
|
|
|
@Test func stripsDashesSpacesParens() {
|
|
#expect(PhoneUtils.normalize("(555) 123-4567") == "+15551234567")
|
|
}
|
|
|
|
@Test func internationalNumbersDigitsOnly() {
|
|
#expect(PhoneUtils.normalize("+44 20 7946 0958") == "+442079460958")
|
|
}
|
|
|
|
@Test func shortNumbersReturnedAsIs() {
|
|
#expect(PhoneUtils.normalize("911") == "911")
|
|
}
|
|
}
|