stripe-ios/Stripe/StripeiOSTests/STPShippingMethodsViewContr...

81 lines
2.2 KiB
Swift

//
// STPShippingMethodsViewControllerLocalizationTests.swift
// StripeiOS Tests
//
// Created by Ben Guo on 11/3/16.
// Copyright © 2016 Stripe, Inc. All rights reserved.
//
import iOSSnapshotTestCase
@testable@_spi(STP) import Stripe
@testable@_spi(STP) import StripeCore
@testable@_spi(STP) import StripePayments
@testable@_spi(STP) import StripePaymentSheet
@testable@_spi(STP) import StripePaymentsUI
class STPShippingMethodsViewControllerLocalizationTests: FBSnapshotTestCase {
override func setUp() {
super.setUp()
// self.recordMode = true
}
func performSnapshotTest(forLanguage language: String?) {
STPLocalizationUtils.overrideLanguage(to: language)
let method1 = PKShippingMethod()
method1.label = "UPS Ground"
method1.detail = "Arrives in 3-5 days"
method1.amount = NSDecimalNumber(string: "0.00")
method1.identifier = "ups_ground"
let method2 = PKShippingMethod()
method2.label = "FedEx"
method2.detail = "Arrives tomorrow"
method2.amount = NSDecimalNumber(string: "5.99")
method2.identifier = "fedex"
let shippingVC = STPShippingMethodsViewController(
shippingMethods: [method1, method2],
selectedShippingMethod: method1,
currency: "usd",
theme: STPTheme.defaultTheme
)
let viewToTest = stp_preparedAndSizedViewForSnapshotTest(from: shippingVC)!
STPSnapshotVerifyView(viewToTest, identifier: nil)
STPLocalizationUtils.overrideLanguage(to: nil)
}
func testGerman() {
performSnapshotTest(forLanguage: "de")
}
func testEnglish() {
performSnapshotTest(forLanguage: "en")
}
func testSpanish() {
performSnapshotTest(forLanguage: "es")
}
func testFrench() {
performSnapshotTest(forLanguage: "fr")
}
func testItalian() {
performSnapshotTest(forLanguage: "it")
}
func testJapanese() {
performSnapshotTest(forLanguage: "ja")
}
func testDutch() {
performSnapshotTest(forLanguage: "nl")
}
func testChinese() {
performSnapshotTest(forLanguage: "zh-Hans")
}
}