mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 09:51:59 +03:00
aac64f2c81
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/1616 GitOrigin-RevId: f7eefd2367929209aa77895ea585e96a99a78d47
17 lines
669 B
Haskell
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
|