-
-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathCommonTests.kt
More file actions
37 lines (32 loc) · 1.16 KB
/
CommonTests.kt
File metadata and controls
37 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import com.linuxcommandlibrary.shared.CommandElement
import com.linuxcommandlibrary.shared.getCommandList
import com.linuxcommandlibrary.shared.toHtmlFileName
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class CommonTests {
@Test
fun testCommandListElements() {
val command = "ps ax | grep firefox"
val elements = command.getCommandList("ps,grep")
assertEquals(elements.count { it is CommandElement.Man }, 2)
}
@Test
fun testHtmlFileName() {
assertEquals("usersgroups".toHtmlFileName(), "usersgroups")
assertEquals("Users & Groups 2".toHtmlFileName(), "usersgroups")
assertEquals("Files & Folders".toHtmlFileName(), "filesfolders")
}
@Test
fun testCommandListWithUrls() {
val command = "install nvm"
val elements = command.getCommandList("url:nvm|https://github.com/nvm-sh/nvm")
assertTrue(elements.any { it is CommandElement.Url })
}
@Test
fun testCommandListEmptyMans() {
val command = "echo hello"
val elements = command.getCommandList("")
assertTrue(elements.all { it is CommandElement.Text })
}
}