Skip to content

Commit

Permalink
Moved hsx testsuite to ihp-hsx package
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Aug 2, 2024
1 parent 040d1b2 commit d87ce54
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 9 deletions.
10 changes: 5 additions & 5 deletions Test/HSX/ParserSpec.hs → ihp-hsx/Test/IHP/HSX/ParserSpec.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{-|
Module: Test.HSX.QQSpec
Module: IHP.HSX.QQSpec
Copyright: (c) digitally induced GmbH, 2020
-}
module Test.HSX.ParserSpec where
module IHP.HSX.ParserSpec where

import Test.Hspec
import IHP.Prelude
import Prelude
import IHP.HSX.Parser
import qualified Text.Megaparsec as Megaparsec
import qualified Text.Megaparsec.Error as Megaparsec
Expand Down Expand Up @@ -62,12 +62,12 @@ tests = do
it "should parse spread values" do
let p = parseHsx position extensions "<div {...variables}/>"
-- We cannot easily construct the @VarE variables@ expression, therefore we use show here for comparison
tshow p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])"
show p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])"

it "should parse spread values with a space" do
-- See https://github.com/digitallyinduced/ihp/issues/1588
let p = parseHsx position extensions "<div { ...variables }/>"
tshow p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])"
show p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])"

it "should accept underscores in data attributes" do
let p = parseHsx position extensions "<div data-client_id=\"test\"/>"
Expand Down
8 changes: 5 additions & 3 deletions Test/HSX/QQSpec.hs → ihp-hsx/Test/IHP/HSX/QQSpec.hs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{-|
Module: Test.HSX.QQSpec
Module: IHP.HSX.QQSpec
Copyright: (c) digitally induced GmbH, 2020
-}
module Test.HSX.QQSpec where
module IHP.HSX.QQSpec where

import Test.Hspec
import IHP.Prelude
import Prelude
import IHP.HSX.QQ
import qualified Text.Blaze.Renderer.Text as Blaze
import Text.Blaze (preEscapedTextValue)
import Data.Text

tests :: SpecWith ()
tests = do
describe "HSX" do
it "should work with static html" do
Expand Down
12 changes: 12 additions & 0 deletions ihp-hsx/Test/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Main where

import Prelude

import Test.Hspec
import qualified IHP.HSX.QQSpec
import qualified IHP.HSX.ParserSpec

main :: IO ()
main = hspec do
IHP.HSX.QQSpec.tests
IHP.HSX.ParserSpec.tests
55 changes: 54 additions & 1 deletion ihp-hsx/ihp-hsx.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,57 @@ library
, IHP.HSX.ConvertibleStrings
, IHP.HSX.HaskellParser
, IHP.HSX.HsExpToTH
, IHP.HSX.Attribute
, IHP.HSX.Attribute

test-suite ihp-hsx-tests
type: exitcode-stdio-1.0
hs-source-dirs: Test
main-is: Main.hs
other-modules:
IHP.HSX.ParserSpec
IHP.HSX.QQSpec
default-language: Haskell2010
build-depends:
base >= 4.17.0 && < 4.20
, ihp-hsx
, hspec
, text >= 2.0.1 && < 2.2
, bytestring >= 0.11.3 && < 0.13
, containers >= 0.6.6 && < 0.7
, blaze-markup
, megaparsec
, template-haskell
default-extensions:
OverloadedStrings
, NoImplicitPrelude
, ImplicitParams
, Rank2Types
, NamedFieldPuns
, TypeSynonymInstances
, FlexibleInstances
, DisambiguateRecordFields
, DuplicateRecordFields
, OverloadedLabels
, FlexibleContexts
, DataKinds
, QuasiQuotes
, TypeFamilies
, PackageImports
, ScopedTypeVariables
, RecordWildCards
, TypeApplications
, DataKinds
, InstanceSigs
, DeriveGeneric
, MultiParamTypeClasses
, TypeOperators
, DeriveDataTypeable
, DefaultSignatures
, BangPatterns
, FunctionalDependencies
, PartialTypeSignatures
, BlockArguments
, LambdaCase
, StandaloneDeriving
, TemplateHaskell
, OverloadedRecordDot

0 comments on commit d87ce54

Please sign in to comment.