mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-30 19:06:41 +03:00
b658df1c43
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4772 Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com> GitOrigin-RevId: 5c6c9056952574462d5b309774331a909a7eac6d
27 lines
918 B
Haskell
27 lines
918 B
Haskell
-- | This module contains auxiliary extentions to hspec
|
|
module Harness.Test.Hspec.Extended
|
|
( mapItemAction,
|
|
)
|
|
where
|
|
|
|
import Hasura.Prelude
|
|
import Test.Hspec
|
|
import Test.Hspec.Core.Spec
|
|
|
|
-- | Modify an 'Item'@ a@ by way of mapping its 'ActionWith'@ a@ function to
|
|
-- some 'ActionWith'@ b@, producing an 'Item'@ b@.
|
|
--
|
|
-- This can be useful when one wants to modify the testEnvironment parameter in a
|
|
-- 'SpecWith' test tree, without having to resolve the type mismatch using some
|
|
-- combination of type families and helper type classes.
|
|
--
|
|
-- NOTE: This should go in some sort of @Test.Hspec.Core.Spec.Extended@ module.
|
|
mapItemAction :: (ActionWith a -> ActionWith b) -> Item a -> Item b
|
|
mapItemAction mapActionWith item@Item {itemExample} =
|
|
let mappedExample params next callback =
|
|
itemExample
|
|
params
|
|
(next . mapActionWith)
|
|
callback
|
|
in item {itemExample = mappedExample}
|