diff --git a/Tests/AcknowExampleTests/AcknowListViewControllerTests.swift b/Tests/AcknowExampleTests/AcknowListViewControllerTests.swift index 4e5cd93..a13a4bf 100644 --- a/Tests/AcknowExampleTests/AcknowListViewControllerTests.swift +++ b/Tests/AcknowExampleTests/AcknowListViewControllerTests.swift @@ -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 { @@ -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 {