From fd5f988288fe25fa0ffdc1e2c267774deb34d4df Mon Sep 17 00:00:00 2001 From: Ruslan Khafizov Date: Wed, 11 Sep 2024 14:11:11 +0800 Subject: [PATCH] Add tests for dump default (#134) --- spago.dhall | 2 ++ src/AnyAll/Ternary.purs | 3 --- src/AnyAll/Types.purs | 8 -------- tests/unit/QuotJs.spec.ts | 37 +++++++++++++++++++++++++++++++++++-- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/spago.dhall b/spago.dhall index ad71701..36d7354 100644 --- a/spago.dhall +++ b/spago.dhall @@ -32,6 +32,8 @@ to generate this file without the comments in this block. , "strings" , "transformers" , "tuples" + , "argonaut-codecs" + , "argonaut-core" ] , packages = ./packages.dhall , sources = [ "src/**/*.purs", "tests/purescript/**/*.purs" ] diff --git a/src/AnyAll/Ternary.purs b/src/AnyAll/Ternary.purs index d51d83d..1e0cd87 100644 --- a/src/AnyAll/Ternary.purs +++ b/src/AnyAll/Ternary.purs @@ -33,9 +33,6 @@ derive instance genericDefault :: Generic (Ternary) _ instance showDefault :: Show (Ternary) where show = genericShow -instance encodeDefault :: Encode (Ternary) where - encode eta = encode $ dumpDefault (eta) - ternary2string ∷ Ternary → String ternary2string True = "true" ternary2string False = "false" diff --git a/src/AnyAll/Types.purs b/src/AnyAll/Types.purs index 1bcd46b..159dfd5 100644 --- a/src/AnyAll/Types.purs +++ b/src/AnyAll/Types.purs @@ -62,14 +62,6 @@ derive instance genericQ :: Generic (Q) _ instance showQ :: Show (Q) where show eta = genericShow eta -type R = - { shouldView :: ShouldView - , andOr :: AndOr String - , tagNL :: Map.Map String String - , prePost :: Maybe (Label String) - , mark :: Ternary - } - -- instance encodeQ :: Encode (Q) where -- encode (Q { shouldView, andOr, tagNL, prePost, mark, children }) = -- genericEncode defaultOptions { shouldView, andOr, prePost, mark, children } diff --git a/tests/unit/QuotJs.spec.ts b/tests/unit/QuotJs.spec.ts index ebc6fdb..add01b9 100644 --- a/tests/unit/QuotJs.spec.ts +++ b/tests/unit/QuotJs.spec.ts @@ -56,7 +56,7 @@ function mkOrResponse(children: any) { } } -describe('evaluate', () => { +describe('qoutjs', () => { it('Asks does the person drink?', () => { expect( AA.qoutjs(mkAskRequest("does the person drink?")) @@ -86,4 +86,37 @@ describe('evaluate', () => { ]) ); }); -}); \ No newline at end of file +}); + +function marked(mark: string) { + return { + "source": "user", + "value": mark + } +} + +describe('Ternary dumpDefault', () => { + it('True', () => { + expect( + AA.dumpDefault(AA.True.value) + ).toEqual( + marked("true") + ); + }); + + it('False', () => { + expect( + AA.dumpDefault(AA.False.value) + ).toEqual( + marked("false") + ); + }); + + it('Unknown', () => { + expect( + AA.dumpDefault(AA.Unknown.value) + ).toEqual( + marked("undefined") + ); + }); +}) \ No newline at end of file