Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sodic committed Oct 7, 2024
1 parent ae76820 commit 7eab0bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions waspc/src/Wasp/AppSpec/Core/Decl.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}

module Wasp.AppSpec.Core.Decl
( Decl,
Expand All @@ -9,16 +10,41 @@ module Wasp.AppSpec.Core.Decl
)
where

import Control.Applicative ((<|>))
import Data.Maybe (mapMaybe)
import Data.Typeable (cast)
import Wasp.AppSpec.Action (Action)
import Wasp.AppSpec.Api (Api)
import Wasp.AppSpec.ApiNamespace (ApiNamespace)
import Wasp.AppSpec.App (App)
import Wasp.AppSpec.Core.IsDecl (IsDecl)
import Wasp.AppSpec.Crud (Crud)
import Wasp.AppSpec.Entity (Entity)
import Wasp.AppSpec.Job (Job)
import Wasp.AppSpec.Page (Page)
import Wasp.AppSpec.Query (Query)
import Wasp.AppSpec.Route (Route)

-- | A container for any (IsDecl a) type, allowing you to have a heterogenous list of
-- Wasp declarations as [Decl].
-- Declarations make the top level of AppSpec.
data Decl where
Decl :: (IsDecl a) => String -> a -> Decl

instance Show Decl where
show decl =
show $
(show <$> fromDecl @Api decl)
<|> (show <$> fromDecl @Route decl)
<|> (show <$> fromDecl @Crud decl)
<|> (show <$> fromDecl @App decl)
<|> (show <$> fromDecl @Action decl)
<|> (show <$> fromDecl @Job decl)
<|> (show <$> fromDecl @Entity decl)
<|> (show <$> fromDecl @Page decl)
<|> (show <$> fromDecl @ApiNamespace decl)
<|> (show <$> fromDecl @Query decl)

-- | Extracts all declarations of a certain type from a @[Decl]@s
takeDecls :: (IsDecl a) => [Decl] -> [(String, a)]
takeDecls = mapMaybe fromDecl
Expand Down
4 changes: 2 additions & 2 deletions waspc/test/AppSpec/FromJSONTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ spec_AppSpecFromJSON = do
}
)
where
extNamedImportJson = [trimming| { "kind": "named", "name" : "foo", "path": "folder/file.js" }|]
extDefaultImportJson = [trimming| { "kind": "default", "name" : "foo", "path": "folder/subfolder/file.js" }|]
extNamedImportJson = [trimming| { "kind": "named", "name" : "foo", "path": "@src/folder/file.js" }|]
extDefaultImportJson = [trimming| { "kind": "default", "name" : "foo", "path": "@src/folder/subfolder/file.js" }|]

fooEntityRef = [trimming| { "name": "foo", "declType": "Entity" }|]
barEntityRef = [trimming| { "name": "bar", "declType": "Entity" }|]
Expand Down

0 comments on commit 7eab0bc

Please sign in to comment.