Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TimeZoneRule for screenshot tests #8045

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
import com.google.testing.junit.testparameterinjector.TestParameter
import com.google.testing.junit.testparameterinjector.TestParameterInjector
import com.stripe.android.financialconnections.getMetadata
import com.stripe.android.financialconnections.utils.TimeZoneRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -34,6 +35,9 @@ class PaparazziSampleScreenshotTest {
PIXEL_C(DeviceConfig.PIXEL_C),
}

@get:Rule
val timeZoneRule = TimeZoneRule()

@get:Rule
val paparazzi = Paparazzi(
environment = detectEnvironment().run {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.stripe.android.financialconnections.utils

import org.junit.rules.TestWatcher
import org.junit.runner.Description
import java.util.TimeZone

class TimeZoneRule(
private val timeZone: TimeZone = TimeZone.getTimeZone("America/Los_Angeles"),
) : TestWatcher() {

private val original: TimeZone = TimeZone.getDefault()

override fun starting(description: Description) {
super.starting(description)
TimeZone.setDefault(timeZone)
}

override fun finished(description: Description) {
TimeZone.setDefault(original)
super.finished(description)
}
}
Loading