-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(replay): Add tests for touch events (#3924)
- Loading branch information
1 parent
ac72abc
commit 5f3a5c8
Showing
9 changed files
with
324 additions
and
107 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...pp/src/test/java/io/sentry/rnsentryandroidtester/RNSentryReplayBreadcrumbConverterTest.kt
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,55 @@ | ||
package io.sentry.rnsentryandroidtester | ||
|
||
import io.sentry.react.RNSentryReplayBreadcrumbConverter | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
@RunWith(JUnit4::class) | ||
class RNSentryReplayBreadcrumbConverterTest { | ||
|
||
@Test | ||
fun doesNotConvertNullPath() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(null) | ||
assertEquals(null, actual) | ||
} | ||
|
||
@Test | ||
fun doesNotConvertPathContainingNull() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(arrayListOf(arrayOfNulls<Any>(1))) | ||
assertEquals(null, actual) | ||
} | ||
|
||
@Test | ||
fun doesNotConvertPathWithValuesMissingNameAndLevel() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(arrayListOf(mapOf( | ||
"element" to "element4", | ||
"file" to "file4"))) | ||
assertEquals(null, actual) | ||
} | ||
|
||
@Test | ||
fun doesConvertValidPathExample1() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(listOf( | ||
mapOf("label" to "label0"), | ||
mapOf("name" to "name1"), | ||
mapOf("name" to "item2", "label" to "label2"), | ||
mapOf("name" to "item3", "label" to "label3", "element" to "element3"), | ||
mapOf("name" to "item4", "label" to "label4", "file" to "file4"), | ||
mapOf("name" to "item5", "label" to "label5", "element" to "element5", "file" to "file5"))) | ||
assertEquals("label3(element3) > label2 > name1 > label0", actual) | ||
} | ||
|
||
@Test | ||
fun doesConvertValidPathExample2() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(listOf( | ||
mapOf("name" to "item2", "label" to "label2"), | ||
mapOf("name" to "item3", "label" to "label3", "element" to "element3"), | ||
mapOf("name" to "item4", "label" to "label4", "file" to "file4"), | ||
mapOf("name" to "item5", "label" to "label5", "element" to "element5", "file" to "file5"), | ||
mapOf("label" to "label6"), | ||
mapOf("name" to "name7"))) | ||
assertEquals("label5(element5, file5) > label4(file4) > label3(element3) > label2", actual) | ||
} | ||
} |
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
5 changes: 5 additions & 0 deletions
5
RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryCocoaTesterTests-Bridging-Header.h
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,5 @@ | ||
// | ||
// Use this file to import your target's public headers that you would like to expose to Swift. | ||
// | ||
|
||
#import "RNSentryReplayBreadcrumbConverter.h" |
47 changes: 47 additions & 0 deletions
47
RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayBreadcrumbConverterTests.swift
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,47 @@ | ||
import XCTest | ||
|
||
final class RNSentryReplayBreadcrumbConverterTests: XCTestCase { | ||
|
||
func testTouchMessageReturnsNilOnEmptyArray() throws { | ||
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: []) | ||
XCTAssertEqual(actual, nil); | ||
} | ||
|
||
func testTouchMessageReturnsNilOnNilArray() throws { | ||
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: nil as [Any]?) | ||
XCTAssertEqual(actual, nil); | ||
} | ||
|
||
func testTouchMessageReturnsNilOnMissingNameAndLevel() throws { | ||
let testPath: [Any?] = [["element": "element4", "file": "file4"]] | ||
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: testPath as [Any]) | ||
XCTAssertEqual(actual, nil); | ||
} | ||
|
||
func testTouchMessageReturnsMessageOnValidPathExample1() throws { | ||
let testPath: [Any?] = [ | ||
["label": "label0"], | ||
["name": "name1"], | ||
["name": "item2", "label": "label2"], | ||
["name": "item3", "label": "label3", "element": "element3"], | ||
["name": "item4", "label": "label4", "file": "file4"], | ||
["name": "item5", "label": "label5", "element": "element5", "file": "file5"], | ||
] | ||
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: testPath as [Any]) | ||
XCTAssertEqual(actual, "label3(element3) > label2 > name1 > label0"); | ||
} | ||
|
||
func testTouchMessageReturnsMessageOnValidPathExample2() throws { | ||
let testPath: [Any?] = [ | ||
["name": "item2", "label": "label2"], | ||
["name": "item3", "label": "label3", "element": "element3"], | ||
["name": "item4", "label": "label4", "file": "file4"], | ||
["name": "item5", "label": "label5", "element": "element5", "file": "file5"], | ||
["label": "label6"], | ||
["name": "name7"], | ||
] | ||
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: testPath as [Any]) | ||
XCTAssertEqual(actual, "label5(element5, file5) > label4(file4) > label3(element3) > label2"); | ||
} | ||
|
||
} |
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
Oops, something went wrong.