git.iko.soy/rowtype-yoga/purescript-yoga-fetch-om
on main help sign in
19 lines 566 B history raw
1module Variant.Spec where
3import Prelude
5import Data.Variant (Variant)
6import Data.Variant as Variant
7import Test.Spec (Spec, describe, it)
8import Test.Spec.Assertions (shouldEqual)
9import Type.Proxy (Proxy(..))
10import Yoga.Fetch.Om.Variant (only)
12spec :: Spec Unit
13spec = describe "only" do
14 it "extracts single variant value - record" do
15 let
16 variant :: Variant (ok :: { id :: Int, name :: String })
17 variant = Variant.inj (Proxy :: _ "ok") { id: 42, name: "Alice" }
18 result = only variant
19 result `shouldEqual` { id: 42, name: "Alice" }