Browse Source

Add a couple of missing tests, coverage badge.

tags/v0.2.1
Chris Smith 5 years ago
parent
commit
2ce9a540f6
2 changed files with 30 additions and 0 deletions
  1. 1
    0
      README.md
  2. 29
    0
      src/test/kotlin/com/dmdirc/ktirc/IrcClientTest.kt

+ 1
- 0
README.md View File

@@ -2,6 +2,7 @@
2 2
 
3 3
 [![Build Status](https://travis-ci.org/csmith/KtIrc.svg?branch=master)](https://travis-ci.org/csmith/KtIrc)
4 4
 [![Codacy Badge](https://api.codacy.com/project/badge/Grade/c01221cbf9cf413ba4d94cb8c80e334a)](https://www.codacy.com/app/csmith/KtIrc?utm_source=github.com&utm_medium=referral&utm_content=csmith/KtIrc&utm_campaign=Badge_Grade)
5
+[![codecov](https://codecov.io/gh/csmith/KtIrc/branch/master/graph/badge.svg)](https://codecov.io/gh/csmith/KtIrc)
5 6
 [![Download](https://api.bintray.com/packages/dmdirc/releases/ktirc/images/download.svg)](https://bintray.com/dmdirc/releases/ktirc/_latestVersion)
6 7
 
7 8
 KtIrc is a Kotlin JVM library for connecting to and interacting with IRC servers.

+ 29
- 0
src/test/kotlin/com/dmdirc/ktirc/IrcClientTest.kt View File

@@ -175,4 +175,33 @@ internal class IrcClientImplTest {
175 175
         }
176 176
     }
177 177
 
178
+    @Test
179
+    fun `IrcClientImpl sends text to socket`() = runBlocking {
180
+        val client = IrcClientImpl(Server(HOST, PORT), Profile(NICK, REAL_NAME, USER_NAME))
181
+        client.socketFactory = mockSocketFactory
182
+        client.connect()
183
+
184
+        // Wait for it to connect
185
+        verify(mockSocket, timeout(500)).sendLine("CAP LS 302")
186
+
187
+        client.send("testing 123")
188
+
189
+        verify(mockSocket, timeout(500)).sendLine("testing 123")
190
+    }
191
+
192
+    @Test
193
+    fun `IrcClientImpl disconnects the socket`() = runBlocking {
194
+        val client = IrcClientImpl(Server(HOST, PORT), Profile(NICK, REAL_NAME, USER_NAME))
195
+        client.socketFactory = mockSocketFactory
196
+        client.connect()
197
+
198
+        // Wait for it to connect
199
+        verify(mockSocket, timeout(500)).sendLine("CAP LS 302")
200
+
201
+        client.disconnect()
202
+
203
+        verify(mockSocket, timeout(500)).disconnect()
204
+    }
205
+
206
+
178 207
 }

Loading…
Cancel
Save