Skip to content

Commit 6481652

Browse files
committed
✅ add test for pre-encoding comma lists in Encoder
1 parent fb454cc commit 6481652

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

qs-kotlin/src/test/kotlin/io/github/techouse/qskotlin/unit/internal/EncoderInternalSpec.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,27 @@ class EncoderInternalSpec :
115115
result.shouldBeInstanceOf<String>()
116116
result shouldBe "ts=X2024-05-01"
117117
}
118+
119+
it("pre-encodes comma lists when encodeValuesOnly is true") {
120+
val seenValues = mutableListOf<String>()
121+
val result =
122+
Encoder.encode(
123+
data = listOf("alpha"),
124+
undefined = false,
125+
sideChannel = mutableMapOf(),
126+
prefix = "tags",
127+
generateArrayPrefix = ListFormat.COMMA.generator,
128+
encodeValuesOnly = true,
129+
encoder = { value, _, _ ->
130+
val text = value?.toString() ?: ""
131+
seenValues += text
132+
"enc:$text"
133+
},
134+
)
135+
136+
seenValues shouldBe listOf("alpha")
137+
result shouldBe listOf("tags[]=enc:alpha")
138+
}
118139
}
119140
})
120141

0 commit comments

Comments
 (0)