@@ -14,6 +14,12 @@ import Test.Hspec
1414data D = S | F deriving (Eq , Show )
1515$ (deriveTypeScript defaultOptions ''D)
1616
17+ data D2 = S2 | F2 deriving (Eq , Show )
18+ $ (deriveTypeScript defaultOptions ''D2 )
19+
20+ data Unit = U deriving (Eq , Show )
21+ $ (deriveTypeScript defaultOptions ''Unit)
22+
1723data PrimeInType' = PrimeInType
1824$ (deriveTypeScript defaultOptions ''PrimeInType')
1925
@@ -47,11 +53,21 @@ tests = describe "Formatting" $ do
4753 formatTSDeclarations' defaultFormattingOptions (getTypeScriptDeclarations @ D Proxy ) `shouldBe`
4854 [i |type D = "S" | "F";|]
4955
50- describe " and the Enum format option is set" $
56+ describe " and the Enum format option is set" $ do
5157 it " should generate a TS Enum" $
5258 formatTSDeclarations' (defaultFormattingOptions { typeAlternativesFormat = Enum }) (getTypeScriptDeclarations @ D Proxy ) `shouldBe`
5359 [i |enum D { S, F }|]
5460
61+ it " should generate a TS Enum with multiple" $
62+ formatTSDeclarations' (defaultFormattingOptions { typeAlternativesFormat = Enum }) (getTypeScriptDeclarations @ D Proxy <> getTypeScriptDeclarations @ D2 Proxy ) `shouldBe`
63+ [__i |enum D { S, F }
64+
65+ enum D2 { S2, F2 }|]
66+
67+ it " should generate a TS Enum from unit" $
68+ formatTSDeclarations' (defaultFormattingOptions { typeAlternativesFormat = Enum }) (getTypeScriptDeclarations @ Unit Proxy ) `shouldBe`
69+ [__i |enum Unit { U }|]
70+
5571 describe " and the EnumWithType format option is set" $
5672 it " should generate a TS Enum with a type declaration" $
5773 formatTSDeclarations' (defaultFormattingOptions { typeAlternativesFormat = EnumWithType }) (getTypeScriptDeclarations @ D Proxy ) `shouldBe`
0 commit comments