Skip to content

Commit

Permalink
Add tests for dump default (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
kharus authored Sep 11, 2024
1 parent 3d1c48a commit fd5f988
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
2 changes: 2 additions & 0 deletions spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
3 changes: 0 additions & 3 deletions src/AnyAll/Ternary.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 0 additions & 8 deletions src/AnyAll/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
37 changes: 35 additions & 2 deletions tests/unit/QuotJs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?"))
Expand Down Expand Up @@ -86,4 +86,37 @@ describe('evaluate', () => {
])
);
});
});
});

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")
);
});
})

0 comments on commit fd5f988

Please sign in to comment.