Skip to content

Instantly share code, notes, and snippets.

View elihart's full-sized avatar

Eli Hart elihart

  • Airbnb
  • San Francisco
View GitHub Profile
@elihart
elihart / MvRxNestedSetSyntaxExample.kt
Created November 20, 2019 17:32
MvRx Nested Set Syntax Example
state("Empty results") {
// Nested copying - gross!
copy(request = Success(request.copy(results = emptyList())))
// A cleaner way to specify the same thing
set {  ::request { success {  ::results } } }.with { emptyList() }
}
@elihart
elihart / MvRxSetSyntaxShortcutsExample.kt
Created November 20, 2019 17:33
MvRx Set Syntax Shortcuts Example
state("Show cancellation policy subtitle") {
set {  ::bookingDetails { success {  ::cancellationSection {  ::showSubtitle } } } }.with { true }
// Can also be written more simply as:
setTrue {  ::bookingDetails { success {  ::cancellationSection {  ::showSubtitle } } } }
}
@elihart
elihart / MvRxSetSyntaxChainingExample.kt
Last active November 20, 2019 18:00
MvRx Set Syntax Chaining Example
state("Not super hosted") {
setFalse {  ::listingDetails { success {  ::isHostedBySuperhost } } }
.setFalse {  ::listingDetails { success {  ::primaryHost {  ::isSuperhost } } } }
}
@elihart
elihart / MvRxMockArgumentSyntaxExample.kt
Last active November 20, 2019 17:49
MvRx Mock Argument Syntax Example
args("No dates") {
setNull {  ::checkInDate }
}
@elihart
elihart / InteractionReportExample.json
Last active November 20, 2019 18:55
Airbnb interaction testing report example
"fragment_container->coordinator_layout->recycler_view->AccountDocumentMarqueeModel->link_text": {
"view": "TextView",
"viewId": "link_text",
"click": [
{
"startActivityFromFragment": {
"activity": "MvRxActivity",
"calledFrom": "AccountLandingFragment",
"extras": "[fragment_class=com.airbnb.android.profile.UserProfileFragment, fragment_args=UserProfileArgs(userId=1)]",
"intentFlags": 0,
@elihart
elihart / InteractionTestingClickResultExample.json
Created November 20, 2019 18:58
Interaction Testing Report Click Result Example
"click": [
{
"startActivityFromFragment": {
"activity": "MvRxActivity",
"calledFrom": "AccountLandingFragment",
"extras": "[fragment_class=com.airbnb.android.profile.UserProfileFragment, fragment_args=UserProfileArgs(userId=1)]",
"intentFlags": 0,
"requestCode": 102
}
}
@elihart
elihart / InteractionTestingExampleActivityFinishing.json
Created November 20, 2019 19:02
Interaction testing example activity finishing
"click": [
{
"Activity finished": {}
},
{
"Activity result set": {
"resultCode": 99,
"resultData": {
"extras": "[RESULT_COUNTRY_CODE=AD, RESULT_PHONE_COUNTRY_CODE=376]"
}
@elihart
elihart / InteractionReportEventExample.json
Created November 20, 2019 19:04
Interaction testing report event example
"click": [
{
"Events logged": {
"ListingElementActionEvent": 2,
"NavigationEvent": 1
}
}
]
@elihart
elihart / InteractionReportViewPropertyExample.json
Created November 20, 2019 19:05
InteractionReportViewPropertyExample
"view": "ExpandableTextView",
"viewId": "text_row_expandable_text_view",
"properties": {
"content description": "We know the area well and are happy to tell you interesting places to visit."
}
@elihart
elihart / InteractionReportImageUrlPropertyExample.json
Created November 20, 2019 19:06
InteractionReportImageUrlPropertyExample
"view": "ImageView",
"viewId": "listing_image",
"properties": {
"url": "https://a0.muscache.com/4ea/air/v2/pictures/22903706/501e0ec5_original.jpg"
}