Skip to content

Commit

Permalink
Add localization tests for default and short language strings
Browse files Browse the repository at this point in the history
  • Loading branch information
James White committed Mar 29, 2016
1 parent 733f96f commit 78c39ff
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Tests/AcknowExampleTests/AcknowListViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ class AcknowListViewControllerTests: XCTestCase {
XCTAssertEqual(cell.textLabel?.text, "AcknowList")
}

func testLocalizedStringReturnsDefault() {

class MockAcknowListViewController: AcknowListViewController {

override class func preferredLanguageCode() -> String {
return "qq-QQ"
}
}

XCTAssertEqual("Acknowledgements", MockAcknowListViewController.localizedString(forKey: "VTAckAcknowledgements", defaultString: ""))

XCTAssertEqual("Generated by CocoaPods", MockAcknowListViewController.localizedString(forKey: "VTAckGeneratedByCocoaPods", defaultString: ""))
}


func testLocalizedStringReturnsEnglish() {

class MockAcknowListViewController: AcknowListViewController {
Expand All @@ -39,6 +54,34 @@ class AcknowListViewControllerTests: XCTestCase {
XCTAssertEqual("Generated by CocoaPods", MockAcknowListViewController.localizedString(forKey: "VTAckGeneratedByCocoaPods", defaultString: ""))
}

func testLocalizedStringReturnsEnglishUS() {

class MockAcknowListViewController: AcknowListViewController {

override class func preferredLanguageCode() -> String {
return "en-US"
}
}

XCTAssertEqual("Acknowledgements", MockAcknowListViewController.localizedString(forKey: "VTAckAcknowledgements", defaultString: ""))

XCTAssertEqual("Generated by CocoaPods", MockAcknowListViewController.localizedString(forKey: "VTAckGeneratedByCocoaPods", defaultString: ""))
}

func testLocalizedStringReturnsFrenchForShortLanguageCode() {

class MockAcknowListViewController: AcknowListViewController {

override class func preferredLanguageCode() -> String {
return "fr"
}
}

XCTAssertEqual("Remerciements", MockAcknowListViewController.localizedString(forKey: "VTAckAcknowledgements", defaultString: ""))

XCTAssertEqual("Généré par CocoaPods", MockAcknowListViewController.localizedString(forKey: "VTAckGeneratedByCocoaPods", defaultString: ""))
}

func testLocalizedStringReturnsFrench() {

class MockAcknowListViewController: AcknowListViewController {
Expand Down

0 comments on commit 78c39ff

Please sign in to comment.