32 lines
1.1 KiB
Kotlin
32 lines
1.1 KiB
Kotlin
package com.example.aiapp
|
|
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertEquals
|
|
import kotlin.test.assertNull
|
|
|
|
class MarkdownLinksTest {
|
|
@Test
|
|
fun `absolute file paths are opened on the session machine`() {
|
|
assertEquals(
|
|
"/home/bob/repos/ai app/Main.kt",
|
|
filePathOf("/home/bob/repos/ai%20app/Main.kt"),
|
|
)
|
|
assertEquals("/home/bob/Main.kt", filePathOf("file:///home/bob/Main.kt"))
|
|
assertEquals("/home/bob/Main.kt", filePathOf("file://localhost/home/bob/Main.kt"))
|
|
}
|
|
|
|
@Test
|
|
fun `editor coordinates select the file itself`() {
|
|
assertEquals("/home/bob/Main.kt", filePathOf("/home/bob/Main.kt:42"))
|
|
assertEquals("/home/bob/Main.kt", filePathOf("file:///home/bob/Main.kt:42:7#L42"))
|
|
}
|
|
|
|
@Test
|
|
fun `ordinary links keep their external meaning`() {
|
|
assertNull(filePathOf("https://example.com/source.kt"))
|
|
assertNull(filePathOf("docs/source.kt"))
|
|
assertNull(filePathOf("//example.com/source.kt"))
|
|
assertNull(filePathOf("file://example.com/source.kt"))
|
|
}
|
|
}
|