Skip to content

Commit

Permalink
Add missing case to FunctionK test
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed Jan 15, 2025
1 parent 585a147 commit a574d48
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ package io.scalaland.chimney.cats
import cats.~>
import cats.data.{Chain, NonEmptyChain, NonEmptyList, NonEmptyMap, NonEmptySeq, NonEmptySet, NonEmptyVector}
import io.scalaland.chimney.ChimneySpec
import io.scalaland.chimney.Transformer
import io.scalaland.chimney.{PartialTransformer, Transformer}
import io.scalaland.chimney.dsl.*

class CatsDataSpec extends ChimneySpec {

test("DSL should always allow transformation when F ~> G is provided and F is Traverse") {
implicit val intToStr: Transformer[Int, String] = _.toString
implicit val strToInt: PartialTransformer[String, Int] = PartialTransformer.fromFunction[String, Int](_.toInt)
implicit val listToOption: List ~> Option = new _root_.cats.arrow.FunctionK[List, Option] {
def apply[A](fa: List[A]): Option[A] = fa.headOption
}

List(1, 2, 3).transformInto[Option[String]] ==> Some("1")
List("1", "2", "3").transformIntoPartial[Option[Int]].asOption ==> Some(Some(1))
}

test("DSL should always allow transformation when outer type has Traverse") {
Expand Down

0 comments on commit a574d48

Please sign in to comment.