This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract phone formatting method (#14)
* refactor and backfill tests for phone number parsing * bump version to 0.0.5
- Loading branch information
1 parent
f5aac96
commit 80671b2
Showing
5 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// PhoneNumberTest.m | ||
// Signal | ||
// | ||
// Created by Michael Kirk on 6/28/16. | ||
// Copyright © 2016 Open Whisper Systems. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "PhoneNumber.h" | ||
|
||
@interface PhoneNumberTest : XCTestCase | ||
|
||
@end | ||
|
||
@implementation PhoneNumberTest | ||
|
||
- (void)testTryParsePhoneNumberFromUserSpecifiedTextAssumesLocalRegion { | ||
PhoneNumber *actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"3235551234"]; | ||
XCTAssertEqualObjects(@"+13235551234", [actual toE164]); | ||
} | ||
|
||
- (void)testTryParsePhoneNumberFromUserSpecifiedTextWithExplicitRegionCode { | ||
PhoneNumber *actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"+33 1 70 39 38 00"]; | ||
XCTAssertEqualObjects(@"+33170393800", [actual toE164]); | ||
} | ||
|
||
- (void)testTryParsePhoneNumberFromUserSpecifiedTextWithoutPlus { | ||
PhoneNumber *actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"33 1 70 39 38 00"]; | ||
|
||
// This might not be desired, but documents existing behavior. | ||
// You *must* include a plus when dialing outside of your locale. | ||
XCTAssertEqualObjects(@"+133170393800", [actual toE164]); | ||
} | ||
|
||
- (void)testTryParsePhoneNumberFromUserSpecifiedTextRemovesAnyFormatting { | ||
PhoneNumber *actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"323 555 1234"]; | ||
XCTAssertEqualObjects(@"+13235551234", [actual toE164]); | ||
|
||
actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"323-555-1234"]; | ||
XCTAssertEqualObjects(@"+13235551234", [actual toE164]); | ||
|
||
actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"323.555.1234"]; | ||
XCTAssertEqualObjects(@"+13235551234", [actual toE164]); | ||
|
||
actual = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:@"1-323-555-1234"]; | ||
XCTAssertEqualObjects(@"+13235551234", [actual toE164]); | ||
} | ||
|
||
@end |