Skip to content

Commit

Permalink
Ensure enum value ordering in all test (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones authored Aug 21, 2023
1 parent 6d8f5e9 commit fae4eaf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/src/test/scala/magnolify/shared/EnumTypeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ class EnumTypeSuite extends MagnolifySuite {

test("JavaEnums CaseMapper") {
val et = ensureSerializable(EnumType[JavaEnums.Color](CaseMapper(_.toLowerCase)))
assertEquals(et.values.toSet, JavaEnums.Color.values().map(_.name().toLowerCase).toSet)
assertEquals(et.values, JavaEnums.Color.values().map(_.name().toLowerCase).toList)
assertEquals(et.from("red"), JavaEnums.Color.RED)
assertEquals(et.to(JavaEnums.Color.RED), "red")
}

test("ScalaEnums CaseMapper") {
val et = ensureSerializable(EnumType[ScalaEnums.Color.Type](CaseMapper(_.toLowerCase)))
assertEquals(et.values.toSet, ScalaEnums.Color.values.map(_.toString.toLowerCase))
assertEquals(et.values, List("red", "green", "blue"))
assertEquals(et.from("red"), ScalaEnums.Color.Red)
assertEquals(et.to(ScalaEnums.Color.Red), "red")
}

test("ADT CaseMapper") {
val et = ensureSerializable(EnumType[ADT.Color](CaseMapper(_.toLowerCase)))
assertEquals(et.values.toSet, Set("red", "green", "blue"))
assertEquals(et.values, List("blue", "green", "red")) // ADTs are ordered alphabetically
assertEquals(et.from("red"), ADT.Red)
assertEquals(et.to(ADT.Red), "red")
}
Expand Down

0 comments on commit fae4eaf

Please sign in to comment.