mirror of
https://github.com/seanhess/hyperbole.git
synced 2024-10-04 00:49:03 +03:00
test, web-view
This commit is contained in:
parent
7288815b61
commit
abd38df740
@ -71,4 +71,6 @@ cabal run
|
||||
In Production
|
||||
-------------
|
||||
|
||||
Hyperbole is used in production by the [National Solar Observatory](https://nso.edu/)
|
||||
<a href="https://nso.edu">
|
||||
<img src="./example/doc/nso.png"/>
|
||||
</a>
|
||||
|
@ -1,4 +1,2 @@
|
||||
packages:
|
||||
.
|
||||
../web-view
|
||||
|
||||
|
BIN
example/doc/nso.png
Normal file
BIN
example/doc/nso.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
@ -6,8 +6,8 @@ cabal-version: 2.2
|
||||
|
||||
name: hyperbole
|
||||
version: 0.3.5
|
||||
synopsis: Interactive Web pages using type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView
|
||||
description: Interactive Web pages using type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView
|
||||
synopsis: Interactive HTML applications using type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView
|
||||
description: Interactive HTML applications using type-safe serverside Haskell. Inspired by HTMX, Elm, and Phoenix LiveView
|
||||
category: Web, Network
|
||||
homepage: https://github.com/seanhess/hyperbole
|
||||
bug-reports: https://github.com/seanhess/hyperbole/issues
|
||||
@ -58,7 +58,7 @@ library
|
||||
, bytestring >=0.11 && <0.13
|
||||
, casing >0.1 && <0.2
|
||||
, containers >=0.6 && <1
|
||||
, cookie
|
||||
, cookie ==0.4.*
|
||||
, effectful >=2.3 && <3
|
||||
, file-embed >=0.0.10 && <0.1
|
||||
, http-api-data ==0.6.*
|
||||
@ -112,7 +112,7 @@ executable examples
|
||||
, bytestring >=0.11 && <0.13
|
||||
, casing >0.1 && <0.2
|
||||
, containers >=0.6 && <1
|
||||
, cookie
|
||||
, cookie ==0.4.*
|
||||
, effectful >=2.3 && <3
|
||||
, file-embed >=0.0.10 && <0.1
|
||||
, http-api-data ==0.6.*
|
||||
@ -158,7 +158,7 @@ test-suite tests
|
||||
, bytestring >=0.11 && <0.13
|
||||
, casing >0.1 && <0.2
|
||||
, containers >=0.6 && <1
|
||||
, cookie
|
||||
, cookie ==0.4.*
|
||||
, effectful >=2.3 && <3
|
||||
, file-embed >=0.0.10 && <0.1
|
||||
, http-api-data ==0.6.*
|
||||
|
@ -51,8 +51,7 @@ dependencies:
|
||||
- wai-websockets >= 3.0 && <4
|
||||
- network >= 3.1 && <4
|
||||
- websockets >= 0.12 && <0.14
|
||||
- cookie
|
||||
# - wai-websockets
|
||||
- cookie >=0.4 && <0.5
|
||||
|
||||
library:
|
||||
source-dirs: src
|
||||
|
@ -12,7 +12,7 @@ import Web.View.Types
|
||||
|
||||
|
||||
data Thing = Thing
|
||||
deriving (Show, Read, Param, Eq)
|
||||
deriving (Generic, Param, Show, Eq)
|
||||
|
||||
|
||||
data Custom = Custom
|
||||
@ -20,19 +20,19 @@ data Custom = Custom
|
||||
|
||||
|
||||
data HasString = HasString String
|
||||
deriving (Show, Read, Param, Eq)
|
||||
deriving (Generic, Param, Show, Eq)
|
||||
|
||||
|
||||
data Compound
|
||||
= One
|
||||
| Two Thing
|
||||
| WithId (Id Thing)
|
||||
deriving (Show, Read, Param, Eq)
|
||||
deriving (Generic, Param, Show, Eq)
|
||||
|
||||
|
||||
newtype Id a = Id {fromId :: Text}
|
||||
deriving newtype (Show, Read, Eq, Ord)
|
||||
deriving (Generic)
|
||||
deriving newtype (Param, Eq, Ord)
|
||||
deriving (Generic, Show)
|
||||
|
||||
|
||||
instance Param Custom where
|
||||
@ -46,12 +46,12 @@ spec = do
|
||||
describe "HyperView" $ do
|
||||
describe "Param" $ do
|
||||
describe "toParam" $ do
|
||||
it "basic" $ toParam Thing `shouldBe` "Thing"
|
||||
it "basic" $ toParam Thing `shouldBe` "thing"
|
||||
it "custom" $ toParam Custom `shouldBe` "something"
|
||||
|
||||
describe "parseParam" $ do
|
||||
it "basic" $ parseParam "Thing" `shouldBe` Just Thing
|
||||
it "basic lowercase" $ parseParam @Thing "thing" `shouldBe` Nothing
|
||||
it "basic" $ parseParam "thing" `shouldBe` Just Thing
|
||||
it "basic lowercase" $ parseParam @Thing "Thing" `shouldBe` Nothing
|
||||
it "custom" $ parseParam "something" `shouldBe` Just Custom
|
||||
it "custom other" $ parseParam @Thing "custom" `shouldBe` Nothing
|
||||
|
||||
@ -64,7 +64,7 @@ spec = do
|
||||
parseParam (toParam inp) `shouldBe` Just inp
|
||||
|
||||
describe "compound" $ do
|
||||
it "should toparam" $ toParam (Two Thing) `shouldBe` "Two Thing"
|
||||
it "should toparam" $ toParam (Two Thing) `shouldBe` "two-thing"
|
||||
it "double roundtrip" $ parseParam (toParam (Two Thing)) `shouldBe` Just (Two Thing)
|
||||
|
||||
describe "Param Attributes" $ do
|
||||
@ -74,15 +74,15 @@ spec = do
|
||||
|
||||
it "should serialize compound id" $ do
|
||||
let atts = mempty :: Attributes
|
||||
(setId (toParam $ Two Thing) atts).other `shouldBe` [("id", "Two Thing")]
|
||||
(setId (toParam $ Two Thing) atts).other `shouldBe` [("id", "two-thing")]
|
||||
|
||||
it "should serialize stringy id" $ do
|
||||
let atts = mempty :: Attributes
|
||||
(setId (toParam $ HasString "woot") atts).other `shouldBe` [("id", "HasString \"woot\"")]
|
||||
(setId (toParam $ HasString "woot") atts).other `shouldBe` [("id", "hasstring-woot")]
|
||||
|
||||
it "should serialize with Id" $ do
|
||||
let atts = mempty :: Attributes
|
||||
(setId (toParam $ WithId (Id "woot")) atts).other `shouldBe` [("id", "WithId \"woot\"")]
|
||||
(setId (toParam $ WithId (Id "woot")) atts).other `shouldBe` [("id", "withid-woot")]
|
||||
|
||||
|
||||
containsSingleQuotes :: Text -> Bool
|
||||
|
Loading…
Reference in New Issue
Block a user