File tree 1 file changed +31
-3
lines changed
parsely/src/test/java/com/parsely/parselyandroid
1 file changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,43 @@ class ParselyAPIConnectionTest {
30
30
assertThat(mockServer.takeRequest().method).isEqualTo(" GET" )
31
31
}
32
32
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
+
33
48
@After
34
49
fun tearDown () {
35
50
mockServer.shutdown()
36
51
}
37
52
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
+
38
68
object FakeTracker : ParselyTracker(
39
- " siteId" ,
40
- 10 ,
41
- ApplicationProvider .getApplicationContext()
69
+ " siteId" , 10 , ApplicationProvider .getApplicationContext()
42
70
) {
43
71
44
72
var flushTimerStopped = false
You can’t perform that action at this time.
0 commit comments