Skip to content

Commit a1b9bd8

Browse files
committed
tests: request with pixels case
1 parent d1e2c85 commit a1b9bd8

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

parsely/src/test/java/com/parsely/parselyandroid/ParselyAPIConnectionTest.kt

+31-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,43 @@ class ParselyAPIConnectionTest {
3030
assertThat(mockServer.takeRequest().method).isEqualTo("GET")
3131
}
3232

33+
@Test
34+
fun `when making connection with events, then make POST request with JSON Content-Type header`() {
35+
// when
36+
sut.execute(
37+
mockServer.url("/").toString(), pixelPayload
38+
)
39+
40+
// then
41+
assertThat(mockServer.takeRequest()).satisfies({
42+
assertThat(it.method).isEqualTo("POST")
43+
assertThat(it.headers["Content-Type"]).isEqualTo("application/json")
44+
assertThat(it.body.readUtf8()).isEqualTo(pixelPayload)
45+
})
46+
}
47+
3348
@After
3449
fun tearDown() {
3550
mockServer.shutdown()
3651
}
3752

53+
companion object {
54+
val pixelPayload = """
55+
{
56+
"events": [
57+
{
58+
"idsite": "example.com"
59+
},
60+
{
61+
"idsite": "example2.com"
62+
}
63+
]
64+
}
65+
""".trimIndent()
66+
}
67+
3868
object FakeTracker : ParselyTracker(
39-
"siteId",
40-
10,
41-
ApplicationProvider.getApplicationContext()
69+
"siteId", 10, ApplicationProvider.getApplicationContext()
4270
) {
4371

4472
var flushTimerStopped = false

0 commit comments

Comments
 (0)