mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
b6799f0882
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8946 GitOrigin-RevId: 434e7c335bc69119020dd35761c7d4539bc51ff8
22 lines
838 B
Haskell
22 lines
838 B
Haskell
module Hasura.GraphQL.NamespaceSpec (spec) where
|
|
|
|
import Data.HashMap.Strict.InsOrd qualified as InsOrdHashMap
|
|
import Hasura.GraphQL.Namespace
|
|
( NamespacedFieldMap,
|
|
flattenNamespaces,
|
|
namespacedField,
|
|
unflattenNamespaces,
|
|
)
|
|
import Hasura.Prelude
|
|
import Hasura.QuickCheck.Instances ()
|
|
import Test.Hspec (Spec, describe, shouldBe)
|
|
import Test.Hspec.QuickCheck (prop)
|
|
|
|
spec :: Spec
|
|
spec = do
|
|
describe "NamespacedField" $ do
|
|
prop "flatten/unflatten roundtrip" $ \(unflattened :: NamespacedFieldMap Int) ->
|
|
-- If all namespaced fields are non-empty then flattening then unflattening should be the identity
|
|
let nonEmptyFields = InsOrdHashMap.filter (namespacedField (const True) $ not . InsOrdHashMap.null) unflattened
|
|
in unflattenNamespaces (flattenNamespaces nonEmptyFields) `shouldBe` nonEmptyFields
|