packages feed

reflex-test-host 0.1.2.2 → 0.1.2.3

raw patch · 5 files changed

+16/−7 lines, 5 filesnew-uploader

Files

ChangeLog.md view
@@ -1,6 +1,9 @@ # Changelog for reflex-test-host  +## 0.1.2.3+- very minor changes to support latest version of ghc+ ## 0.1.2.2 - add `fireQueuedEvents` - switch over to cabal instead of stack
README.md view
@@ -1,6 +1,6 @@ # reflex-test-host -This library contains functionality for writing unit tests for the "model" portion of your reflex-frp apps. Please see "test/Reflex/Test/SimpleHostSpec.hs" for basic usage example. You can find more usage examples in [this project](https://github.com/pdlla/reflex-potatoes?files=1) and [this one](https://github.com/pdlla/reflex-todo-undo-mvc-model).+This library contains functionality for writing unit tests for the "model" portion of your reflex-frp apps. Please see "test/Reflex/Test/SimpleHostSpec.hs" for basic usage example. You can find more usage examples in [this project](https://github.com/minimapletinytools/reflex-potatoes?files=1) and [this one](https://github.com/minimapletinytools/reflex-todo-undo-mvc-model).  Note that `TriggerEvent` class constraint is not supported. It could be added with some effort but breaks the "pureness" of the test (at least from its inputs) so I don't suggest it. You can still test parts of your network that don't require `TriggerEvent`. 
reflex-test-host.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           reflex-test-host-version:        0.1.2.2+version:        0.1.2.3 synopsis:       reflex host methods for testing without external events description:    Please see the README on GitHub at <https://github.com/pdlla/reflex-test-host#readme> category:       FRP, Reflex@@ -20,6 +20,10 @@ extra-source-files:     README.md     ChangeLog.md+++tested-with:+  GHC == 9.6.2  source-repository head   type: git
src/Reflex/Test/Monad/Host.hs view
@@ -30,6 +30,7 @@ import           Control.Concurrent.Chan import           Control.Monad.IO.Class +import           Control.Monad.Fix import           Control.Monad.Primitive import           Control.Monad.Reader import           Control.Monad.Ref
test/Reflex/Test/Monad/HostSpec.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE RecordWildCards      #-} {-# LANGUAGE UndecidableInstances #-} + module Reflex.Test.Monad.HostSpec   ( spec   )@@ -70,7 +71,7 @@  test_basic_viaReflexTestApp :: Test test_basic_viaReflexTestApp = TestLabel "basic_viaReflexTestApp" $ TestCase $ runSpiderHost $-  runReflexTestApp @ (BasicNetworkTest1 (SpiderTimeline Global) (SpiderHost Global)) $ do+  runReflexTestApp @(BasicNetworkTest1 (SpiderTimeline Global) (SpiderHost Global)) $ do     -- get our app's output events and subscribe to them     BasicNetworkTest1_Output {..} <- outputs     oh                            <- subscribeEvent _basicNetworkTest1_Output_intEv@@ -81,15 +82,15 @@     -- fire it     queueEventTriggerRef _basicNetworkTest1_InputTriggerRefs_intEvTRef 123     -- fire the events and read from our output handle-    a <- fireQueuedEventsAndRead $ sequence =<< readEvent oh+    a1 <- fireQueuedEventsAndRead $ sequence =<< readEvent oh      -- validate results-    liftIO $ a @?= [Just 123]+    liftIO $ a1 @?= [Just 123]      -- try a different value     queueEventTriggerRef _basicNetworkTest1_InputTriggerRefs_intEvTRef 238-    a <- fireQueuedEventsAndRead $ sequence =<< readEvent oh-    liftIO $ a @?= [Just 238]+    a2 <- fireQueuedEventsAndRead $ sequence =<< readEvent oh+    liftIO $ a2 @?= [Just 238]   spec :: Spec