graphql-engine/server/src-test/Hasura/GraphQL/NamespaceSpec.hs
David Overton aac64f2c81 Source typename customization (close graphql-engine#6974)
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/1616
GitOrigin-RevId: f7eefd2367929209aa77895ea585e96a99a78d47
2021-10-29 14:43:14 +00:00

17 lines
669 B
Haskell

module Hasura.GraphQL.NamespaceSpec (spec) where
import Data.HashMap.Strict.InsOrd qualified as OMap
import Hasura.Generator ()
import Hasura.GraphQL.Namespace
import Hasura.Prelude
import Test.Hspec
import Test.Hspec.QuickCheck
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 = OMap.filter (namespacedField (const True) $ not . OMap.null) unflattened
in unflattenNamespaces (flattenNamespaces nonEmptyFields) `shouldBe` nonEmptyFields