-
Notifications
You must be signed in to change notification settings - Fork 2
/
PipeSpec.hs
39 lines (28 loc) · 1.1 KB
/
PipeSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Dolla.Consensus.Proposing.Staging.Pipes.NonEmptying.PipeSpec
(spec) where
import Test.QuickCheck.Instances ()
import Test.Hspec
import Test.QuickCheck
import qualified Streamly.Prelude as S
import qualified Streamly.Internal.Prelude as S
import Dolla.Consensus.Proposing.Staging.Pipes.NonEmptying.Pipe (nonEmptying)
import Data.Function ((&))
spec :: Spec
spec = do
describe "NonEmptying" $ do
it "The first event emitted is never Nothing"
$ property $ \inputs
-> do
firstEvent <- S.fromList (inputs :: [Maybe ()])
& nonEmptying
& S.head
firstEvent `shouldNotBe` Just Nothing
it "Nothings are never emitted consecutively"
$ property $ \inputs
-> S.fromList (inputs :: [Maybe ()])
& nonEmptying
& S.rollingMap (,)
& S.mapM_ (`shouldNotBe` (Nothing,Nothing))