|
1 | 1 | package io.github.nomisrev |
2 | 2 |
|
3 | | -import io.kotest.common.Platform |
4 | | -import io.kotest.common.platform |
5 | 3 | import io.kotest.core.spec.style.StringSpec |
6 | 4 | import io.kotest.matchers.nulls.shouldBeNull |
7 | 5 | import io.kotest.matchers.shouldBe |
@@ -99,63 +97,62 @@ class JsonDSLSpec : StringSpec({ |
99 | 97 | JsonPath.select("streets").getOrNull(cityJson) shouldBe (cityJson as? JsonObject)?.get("streets") |
100 | 98 | } |
101 | 99 | } |
102 | | - |
103 | | - // See https://github.com/Kotlin/kotlinx.serialization/issues/1914 |
104 | | - "extract from object".config(enabled = platform != Platform.Native) { |
| 100 | + |
| 101 | + "extract from object" { |
105 | 102 | checkAll(Arb.json(Arb.city())) { cityJson -> |
106 | 103 | JsonPath.extract(City.serializer()) |
107 | 104 | .getOrNull(cityJson) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson) |
108 | 105 | } |
109 | 106 | } |
110 | 107 |
|
111 | | - "get from array, using select and get".config(enabled = platform != Platform.Native) { |
| 108 | + "get from array, using select and get" { |
112 | 109 | checkAll(Arb.json(Arb.city())) { cityJson -> |
113 | 110 | JsonPath.select("streets")[0] |
114 | 111 | .extract(Street.serializer()) |
115 | 112 | .getOrNull(cityJson) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson).streets.getOrNull(0) |
116 | 113 | } |
117 | 114 | } |
118 | 115 |
|
119 | | - "get from array, using get".config(enabled = platform != Platform.Native) { |
| 116 | + "get from array, using get" { |
120 | 117 | checkAll(Arb.json(Arb.city())) { cityJson -> |
121 | 118 | JsonPath["streets"][0]["name"].string |
122 | 119 | .getOrNull(cityJson) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson).streets.getOrNull(0)?.name |
123 | 120 | } |
124 | 121 | } |
125 | 122 |
|
126 | | - "get from array, using get".config(enabled = platform != Platform.Native) { |
| 123 | + "get from array, using get range" { |
127 | 124 | checkAll(Arb.json(Arb.city())) { cityJson -> |
128 | 125 | JsonPath["streets"][0..0]["name"].string |
129 | 126 | .getAll(cityJson) |
130 | 127 | .getOrNull(0) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson).streets.getOrNull(0)?.name |
131 | 128 | } |
132 | 129 | } |
133 | 130 |
|
134 | | - "get from array, using select with special syntax".config(enabled = platform != Platform.Native) { |
| 131 | + "get from array, using select with special syntax" { |
135 | 132 | checkAll(Arb.json(Arb.city())) { cityJson -> |
136 | 133 | JsonPath.select("['streets']").select("[0]") |
137 | 134 | .extract(Street.serializer()) |
138 | 135 | .getOrNull(cityJson) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson).streets.getOrNull(0) |
139 | 136 | } |
140 | 137 | } |
141 | 138 |
|
142 | | - "get from array, using path".config(enabled = platform != Platform.Native) { |
| 139 | + "get from array, using path" { |
143 | 140 | checkAll(Arb.json(Arb.city())) { cityJson -> |
144 | 141 | JsonPath.path("streets[0]") |
145 | 142 | .extract(Street.serializer()) |
146 | 143 | .getOrNull(cityJson) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson).streets.getOrNull(0) |
147 | 144 | } |
148 | 145 | } |
149 | 146 |
|
150 | | - "get all elements from array".config(enabled = platform != Platform.Native) { |
| 147 | + "get all elements from array" { |
151 | 148 | checkAll(Arb.json(Arb.city())) { cityJson -> |
152 | 149 | JsonPath.select("streets").selectEvery("*").select("name") |
153 | 150 | .string |
154 | 151 | .getAll(cityJson) shouldBe Json.decodeFromJsonElement(City.serializer(), cityJson).streets.map { it.name } |
155 | 152 | } |
156 | 153 | } |
157 | 154 |
|
158 | | - "get all elements from array, using path".config(enabled = platform != Platform.Native) { |
| 155 | + "get all elements from array, using path" { |
159 | 156 | checkAll(Arb.json(Arb.city())) { cityJson -> |
160 | 157 | JsonPath.pathEvery("streets.*.name") |
161 | 158 | .string |
|
0 commit comments