mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: replace unMock with Hilt testing
This commit is contained in:
parent
e4c6000a10
commit
407febc5f8
4 changed files with 34 additions and 14 deletions
|
|
@ -1,47 +0,0 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import android.net.Uri
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class ChannelSetTest {
|
||||
|
||||
/** make sure we match the python and device code behavior */
|
||||
@Test
|
||||
fun matchPython() {
|
||||
val url = Uri.parse("https://meshtastic.org/e/#CgMSAQESBggBQANIAQ")
|
||||
val cs = url.toChannelSet()
|
||||
Assert.assertEquals("LongFast", cs.primaryChannel!!.name)
|
||||
Assert.assertEquals(url, cs.getChannelUrl(false))
|
||||
}
|
||||
|
||||
/** validate against the host or path in a case-insensitive way */
|
||||
@Test
|
||||
fun parseCaseInsensitive() {
|
||||
var url = Uri.parse("HTTPS://MESHTASTIC.ORG/E/#CgMSAQESBggBQANIAQ")
|
||||
Assert.assertEquals("LongFast", url.toChannelSet().primaryChannel!!.name)
|
||||
|
||||
url = Uri.parse("HTTPS://mEsHtAsTiC.OrG/e/#CgMSAQESBggBQANIAQ")
|
||||
Assert.assertEquals("LongFast", url.toChannelSet().primaryChannel!!.name)
|
||||
}
|
||||
|
||||
/** properly parse channel config when `?add=true` is in the fragment */
|
||||
@Test
|
||||
fun handleAddInFragment() {
|
||||
val url = Uri.parse("https://meshtastic.org/e/#CgMSAQESBggBQANIAQ?add=true")
|
||||
val cs = url.toChannelSet()
|
||||
val shouldAdd = url.shouldAddChannels()
|
||||
Assert.assertEquals("LongFast", cs.primaryChannel!!.name)
|
||||
Assert.assertTrue(shouldAdd)
|
||||
}
|
||||
|
||||
/** properly parse channel config when `?add=true` is in the query parameters */
|
||||
@Test
|
||||
fun handleAddInQueryParams() {
|
||||
val url = Uri.parse("https://meshtastic.org/e/?add=true#CgMSAQESBggBQANIAQ")
|
||||
val cs = url.toChannelSet()
|
||||
val shouldAdd = url.shouldAddChannels()
|
||||
Assert.assertEquals("LongFast", cs.primaryChannel!!.name)
|
||||
Assert.assertTrue(shouldAdd)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue