-
Notifications
You must be signed in to change notification settings - Fork 51
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 unit test on iOS #764
Merged
Merged
Add unit test on iOS #764
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d42769c
add test func.
ianlin-bbpos 5260769
Example of using a mirror protocol for testing allowing a mock struct to
bric-stripe c2715c1
derp; I forgot to git add the Protocols.swift file
bric-stripe ecfa160
implement mapper test & add test command in bitrise.yml.
ianlin-bbpos d64b62e
improve test method.
ianlin-bbpos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import StripeTerminal | ||
|
||
/** | ||
This file includes a collection of protocols that mirror a selection of the StripeTerminal iOS public classes. | ||
This enables writing swift unit tests against these protocols since the Terminal iOS SDK | ||
classes prevent instantiating them (init and new are annotated as unavailable). | ||
|
||
Note the naming here is exactly as they are named in the native SDK so we can use them interchangeably. We will | ||
need to keep them in sync. | ||
*/ | ||
|
||
protocol CollectInputsResult { | ||
var skipped: Bool { get } | ||
} | ||
|
||
protocol TextResult : CollectInputsResult { | ||
var text: String? { get } | ||
var toggles: [NSNumber] { get } | ||
} | ||
|
||
protocol NumericResult : CollectInputsResult { | ||
var numericString: String? { get } | ||
var toggles: [NSNumber] { get } | ||
} | ||
|
||
protocol PhoneResult : CollectInputsResult { | ||
var phone: String? { get } | ||
var toggles: [NSNumber] { get } | ||
} | ||
|
||
protocol EmailResult : CollectInputsResult { | ||
var email: String? { get } | ||
var toggles: [NSNumber] { get } | ||
} | ||
|
||
protocol SignatureResult : CollectInputsResult { | ||
var signatureSvg: String? { get } | ||
var toggles: [NSNumber] { get } | ||
} | ||
|
||
protocol SelectionResult : CollectInputsResult { | ||
var selection: String? { get } | ||
var toggles: [NSNumber] { get } | ||
} | ||
|
||
extension StripeTerminal.TextResult : TextResult { | ||
} | ||
|
||
extension StripeTerminal.NumericResult : NumericResult { | ||
} | ||
|
||
extension StripeTerminal.PhoneResult : PhoneResult { | ||
} | ||
|
||
extension StripeTerminal.EmailResult : EmailResult { | ||
} | ||
|
||
extension StripeTerminal.SignatureResult : SignatureResult { | ||
} | ||
|
||
extension StripeTerminal.SelectionResult : SelectionResult { | ||
} | ||
|
||
extension StripeTerminal.CollectInputsResult : CollectInputsResult { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
"get:testbutler": "curl -f -o ./test-butler-app.apk https://repo1.maven.org/maven2/com/linkedin/testbutler/test-butler-app/2.2.1/test-butler-app-2.2.1.apk", | ||
"docs": "npx typedoc ./src/index.tsx --out ./docs/api-reference --tsconfig ./tsconfig.json --readme none", | ||
"unit-test:android": "cd android && ./gradlew testDebugUnitTest", | ||
"unit-test:ios": "xcodebuild test -workspace dev-app/ios/StripeTerminalReactNativeDevApp.xcworkspace -destination 'platform=iOS Simulator,name=iPhone 15' -scheme UnitTests", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, thanks for adding |
||
"unit-test:js": "jest" | ||
}, | ||
"keywords": [ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why we have this for TextResult only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I think I missed the others, but the compilation and testing still passed. I know that CollectInputsResult is essential. As for the other missing ones, I also wonder if it is because they already have definitions inherited from CollectInputsResult in the native sdk? let me add the missing ones.