-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for extracting display name from email address (#20410)
- Loading branch information
Showing
3 changed files
with
69 additions
and
16 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
26 changes: 26 additions & 0 deletions
26
WordPress/WordPressTest/NUX/SignupEpilogueTableViewControllerTests.swift
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,26 @@ | ||
import Nimble | ||
@testable import WordPress | ||
import XCTest | ||
|
||
class SignupEpilogueTableViewControllerTests: XCTestCase { | ||
|
||
typealias SUT = SignupEpilogueTableViewController | ||
|
||
// Keeps everything before the "@" and capitalizes it | ||
func testGenerateDisplayName() { | ||
expect(SUT.self.generateDisplayName(from: "[email protected]")) == "Test" | ||
expect(SUT.self.generateDisplayName(from: "[email protected]")) == "Foo" | ||
} | ||
|
||
func testGenerateDisplayNameSplitsEmailComponents() { | ||
expect(SUT.self.generateDisplayName(from: "[email protected]")) == "Test Name" | ||
expect(SUT.self.generateDisplayName(from: "[email protected]")) == "Test Name Foo" | ||
} | ||
|
||
// See discussion in method definition for the rationale behind this behavior. | ||
func testGenerateDisplayNameHandlesNonEmails() { | ||
expect(SUT.self.generateDisplayName(from: "string")) == "String" | ||
expect(SUT.self.generateDisplayName(from: "not.an.email")) == "Not An Email" | ||
expect(SUT.self.generateDisplayName(from: "not an email")) == "Notanemail" | ||
} | ||
} |