@@ -15,6 +15,7 @@ import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
15
15
import io.kotest.matchers.collections.shouldHaveAtLeastSize
16
16
import io.kotest.matchers.collections.shouldHaveAtMostSize
17
17
import io.kotest.matchers.collections.shouldHaveSize
18
+ import io.kotest.matchers.maps.shouldContainExactly
18
19
import io.kotest.matchers.shouldBe
19
20
import io.kotest.matchers.shouldNotBe
20
21
import io.kotest.matchers.string.shouldContain
@@ -26,7 +27,7 @@ val random = Random()
26
27
27
28
internal class FakerServiceTest : DescribeSpec ({
28
29
describe("locale for the dictionary") {
29
- context("it is set to default value") {
30
+ context("is set to default value") {
30
31
it("it should load the category for 'en' locale") {
31
32
fakerService(YamlCategory .ADDRESS )
32
33
.dictionary
@@ -49,7 +50,7 @@ internal class FakerServiceTest : DescribeSpec({
49
50
}
50
51
}
51
52
52
- context("it is set to custom value") {
53
+ context("is set to custom value") {
53
54
it("matching keys should be overwritten in the localized dictionary") {
54
55
val esAddress = fakerService("es", YamlCategory .ADDRESS ).dictionary.getEntryByCategory("address")
55
56
val defaultAddress = fakerService(YamlCategory .ADDRESS ).dictionary.getEntryByCategory("address")
@@ -98,13 +99,13 @@ internal class FakerServiceTest : DescribeSpec({
98
99
}
99
100
}
100
101
101
- context("it is set with a valid String value") {
102
+ context("is set with a valid String value") {
102
103
it("localized category should be loaded") {
103
104
fakerService("es", YamlCategory .ADDRESS ).dictionary shouldNotBe emptyMap<YamlCategory , Map <* , * >>()
104
105
}
105
106
}
106
107
107
- context("it is set with invalid String value") {
108
+ context("is set with invalid String value") {
108
109
it("an exception is thrown when loading the category") {
109
110
val exception = shouldThrow<IllegalArgumentException > {
110
111
fakerService("pe", YamlCategory .ADDRESS )
@@ -114,24 +115,17 @@ internal class FakerServiceTest : DescribeSpec({
114
115
}
115
116
}
116
117
117
- // TODO not supported since 1.11.0
118
- // see: https://github.com/serpro69/kotlin-faker/issues/131
119
- // Note: when implemented also add tests to check that existing `lang-COUNTRY` locale is actually loaded, e.g. `fr-CA`
120
- // context("it is set as `lang-COUNTRY` but dictionary file exists only for `lang`") {
121
- // val frFRDict = FakerService(Faker(), "fr-FR").dictionary
122
- //
123
- // it("localized dictionary for `lang` should be loaded") {
124
- // frFRDict shouldNotBe null
125
- // }
126
- // }
127
- //
128
- // context("it is set as `lang_COUNTRY` String") {
129
- // val frFRDict = FakerService(Faker(), "fr_FR").dictionary
130
- //
131
- // it("it should be set as `lang-COUNTRY` String") {
132
- // frFRDict shouldNotBe null
133
- // }
134
- // }
118
+ context("is set as `lang-COUNTRY ` but dictionary file exists only for `lang`") {
119
+ val service = FakerService (Faker (), Locale .forLanguageTag("de-DE "))
120
+
121
+ @Suppress(" LocalVariableName" )
122
+ val `de-DE Dictionary ` = service.load(YamlCategory .ADDRESS )
123
+
124
+ it("localized dictionary for `lang` should be loaded") {
125
+ `de-DE Dictionary ` shouldContainExactly FakerService (Faker (), Locale .forLanguageTag("de"))
126
+ .load(YamlCategory .ADDRESS )
127
+ }
128
+ }
135
129
}
136
130
137
131
describe("dictionary is loaded") {
@@ -549,6 +543,29 @@ internal class FakerServiceTest : DescribeSpec({
549
543
jaCat[" breed" ] shouldNotBe defaultCat[" breed" ]
550
544
}
551
545
}
546
+
547
+ // context("fr locale") { // also applicable for ja and any other multi-file localized data
548
+ // // TODO not supported since 1.11.0
549
+ // // see: https://github.com/serpro69/kotlin-faker/issues/131
550
+ // // Note: when implemented also add tests to check that existing `lang-COUNTRY` locale is actually loaded, e.g. `fr-CA`
551
+ // context("it is set as `lang-COUNTRY` but dictionary file exists only for `lang`") {
552
+ // val frFRDict = FakerService(Faker(), Locale.forLanguageTag("fr-FR")).dictionary
553
+ //
554
+ // it("localized dictionary for `lang` should be loaded") {
555
+ // frFRDict shouldNotBe null
556
+ // frFRDict shouldNotBe emptyMap<YamlCategory, YamlCategoryData>()
557
+ // }
558
+ // }
559
+ //
560
+ // context("it is set as `lang_COUNTRY` String") {
561
+ // val frFRDict = FakerService(Faker(), Locale.forLanguageTag("fr_FR")).dictionary
562
+ //
563
+ // it("it should be set as `lang-COUNTRY` String") {
564
+ // frFRDict shouldNotBe null
565
+ // frFRDict shouldNotBe emptyMap<YamlCategory, YamlCategoryData>()
566
+ // }
567
+ // }
568
+ // }
552
569
}
553
570
})
554
571
0 commit comments