Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-reactix
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-reactix
Commits
3379abbd
Commit
3379abbd
authored
Jan 13, 2020
by
Justin Woo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tests
parent
87165299
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
33 deletions
+37
-33
Main.purs
test/Main.purs
+5
-5
Spec.purs
test/Reactix/React/Spec.purs
+32
-28
No files found.
test/Main.purs
View file @
3379abbd
...
@@ -3,14 +3,14 @@ module Test.Main where
...
@@ -3,14 +3,14 @@ module Test.Main where
import Prelude
import Prelude
import Effect (Effect)
import Effect (Effect)
import Test.Spec (Spec)
import Effect.Aff (Aff)
import Test.Spec.Mocha (runMocha)
import Reactix.React.Spec as ReactSpec
import Reactix.React.Spec as ReactSpec
import Test.Spec (SpecT)
import Test.Spec.Mocha (runMocha)
specs :: Spec Unit
specs :: Spec
T Aff Unit Effect
Unit
specs = do ReactSpec.spec
specs = do ReactSpec.spec
main :: Effect Unit
main :: Effect Unit
main = do
main = do
runMocha
$ pure
specs
runMocha specs
test/Reactix/React/Spec.purs
View file @
3379abbd
module Reactix.React.Spec where
module Reactix.React.Spec where
import Prelude
import Prelude
import DOM.Simple.Element as Element
import DOM.Simple.Types (Element)
import Data.Array ((!!))
import Data.Array as A
import Data.Array as A
import Data.Array ( (!!) )
import Data.Maybe (Maybe(..))
import Data.Maybe ( Maybe(..) )
import Data.Traversable (sequence_, traverse_)
import Data.Traversable (sequence_, traverse_)
import Data.Tuple.Nested (
(/\)
)
import Data.Tuple.Nested (
(/\)
)
import Data.Unfoldable (fromMaybe)
import Data.Unfoldable (fromMaybe)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (
liftEffect
)
import Effect.Class (
liftEffect
)
import Effect.Ref as Ref
import Effect.Ref as Ref
import Test.Spec ( Spec, describe, it )
import Test.Spec.Assertions ( shouldEqual )
import DOM.Simple.Element as Element
import DOM.Simple.Types (Element)
import FFI.Simple (delay)
import FFI.Simple (delay)
import Reactix as R
import Reactix as R
import Reactix.Test as RT
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Reactix.Test as RT
import Test.Spec (SpecT, describe, it)
import Test.Spec.Assertions (shouldEqual)
staticTest :: Spec Unit
type Spec = SpecT Aff Unit Effect Unit
staticTest :: Spec
staticTest =
staticTest =
describe "Basic DOM rendering" $ do
describe "Basic DOM rendering" $ do
it "Simple elements" $ do
it "Simple elements" $ do
...
@@ -65,7 +69,7 @@ counterCpt = R.hooksComponent "Counter" cpt
...
@@ -65,7 +69,7 @@ counterCpt = R.hooksComponent "Counter" cpt
[ H.button { type: "button", on: { click: \_ -> setY (_ + 1) } } [ H.text "++" ]
[ H.button { type: "button", on: { click: \_ -> setY (_ + 1) } } [ H.text "++" ]
, H.div {} [ H.text (show y) ] ]
, H.div {} [ H.text (show y) ] ]
counterTest :: Spec
Unit
counterTest :: Spec
counterTest =
counterTest =
describe "Counter" do
describe "Counter" do
it "Works for plain components" $ do
it "Works for plain components" $ do
...
@@ -109,7 +113,7 @@ bicounterCpt = R.hooksComponent "Bicounter" cpt
...
@@ -109,7 +113,7 @@ bicounterCpt = R.hooksComponent "Bicounter" cpt
reduce count Inc = count + 1
reduce count Inc = count + 1
reduce count Dec = count - 1
reduce count Dec = count - 1
bicounterTest :: Spec
Unit
bicounterTest :: Spec
bicounterTest =
bicounterTest =
describe "Bicounter" do
describe "Bicounter" do
it "Works for plain components" $ do
it "Works for plain components" $ do
...
@@ -141,7 +145,7 @@ bicounterTest =
...
@@ -141,7 +145,7 @@ bicounterTest =
let children5 = Element.children root.container >>= Element.children
let children5 = Element.children root.container >>= Element.children
A.length children5 `shouldEqual` 3
A.length children5 `shouldEqual` 3
(Element.innerHTML <$> children4) `shouldEqual` ["++", "--", "1"]
(Element.innerHTML <$> children4) `shouldEqual` ["++", "--", "1"]
data EffectorState = Fresh | Initialised | Done
data EffectorState = Fresh | Initialised | Done
derive instance eqEffectorState :: Eq EffectorState
derive instance eqEffectorState :: Eq EffectorState
...
@@ -162,7 +166,7 @@ effectorCpt = R.hooksComponent "Effector" cpt
...
@@ -162,7 +166,7 @@ effectorCpt = R.hooksComponent "Effector" cpt
pure $ H.div {} []
pure $ H.div {} []
-- TODO: test it's firing at the right time
-- TODO: test it's firing at the right time
effectorTest :: Spec
Unit
effectorTest :: Spec
effectorTest =
effectorTest =
describe "Effector" do
describe "Effector" do
it "Works for plain components" $
it "Works for plain components" $
...
@@ -190,7 +194,7 @@ layoutEffectorCpt = R.hooksComponent "LayoutEffector" cpt
...
@@ -190,7 +194,7 @@ layoutEffectorCpt = R.hooksComponent "LayoutEffector" cpt
pure $ H.div {} []
pure $ H.div {} []
-- TODO: test it's firing at the right time
-- TODO: test it's firing at the right time
layoutEffectorTest :: Spec
Unit
layoutEffectorTest :: Spec
layoutEffectorTest =
layoutEffectorTest =
describe "LayoutEffector" do
describe "LayoutEffector" do
it "Works for plain components" $
it "Works for plain components" $
...
@@ -246,13 +250,13 @@ themeChooserCpt = R.hooksComponent "ThemeChooser" cpt
...
@@ -246,13 +250,13 @@ themeChooserCpt = R.hooksComponent "ThemeChooser" cpt
[ H.text "Light" ]
[ H.text "Light" ]
, R.provideContext context theme [ R.createElement themedCpt { theme: context } [] ] ]
, R.provideContext context theme [ R.createElement themedCpt { theme: context } [] ] ]
themeChooserTest :: Spec
Unit
themeChooserTest :: Spec
themeChooserTest =
themeChooserTest =
describe "ThemeChooser" do
describe "ThemeChooser" do
it "Works for plain components" $ do
it "Works for plain components" $ do
let themeChooser = R.createElement themeChooserCpt {} []
let themeChooser = R.createElement themeChooserCpt {} []
liftEffect (RT.render themeChooser) >>= test
liftEffect (RT.render themeChooser) >>= test
where
where
test root = do
test root = do
let children = Element.children root.container
let children = Element.children root.container
A.length children `shouldEqual` 1
A.length children `shouldEqual` 1
...
@@ -272,8 +276,8 @@ themeChooserTest =
...
@@ -272,8 +276,8 @@ themeChooserTest =
let children5 = (Element.children root.container) >>= Element.children
let children5 = (Element.children root.container) >>= Element.children
A.length children5 `shouldEqual` 4
A.length children5 `shouldEqual` 4
(Element.innerHTML <$> children5) `shouldEqual` ["None", "Dark", "Light", "light"]
(Element.innerHTML <$> children5) `shouldEqual` ["None", "Dark", "Light", "light"]
-- type FizzBuzzProps = ( context :: R.Context Int )
-- type FizzBuzzProps = ( context :: R.Context Int )
-- fizzBuzzCpt :: R.Component FizzBuzzProps
-- fizzBuzzCpt :: R.Component FizzBuzzProps
...
@@ -293,7 +297,7 @@ themeChooserTest =
...
@@ -293,7 +297,7 @@ themeChooserTest =
-- | count `mod` 5 == 0 = "Buzz"
-- | count `mod` 5 == 0 = "Buzz"
-- | true = show count
-- | true = show count
-- fizzBuzzTest :: Spec
Unit
-- fizzBuzzTest :: Spec
-- fizzBuzzTest =
-- fizzBuzzTest =
-- describe "FizzBuzz" do
-- describe "FizzBuzz" do
-- it "Works for plain components" $
-- it "Works for plain components" $
...
@@ -304,19 +308,19 @@ themeChooserTest =
...
@@ -304,19 +308,19 @@ themeChooserTest =
-- test :: forall cpt. R.IsComponent cpt FizzBuzzProps (Array R.Element) => cpt -> Aff Unit
-- test :: forall cpt. R.IsComponent cpt FizzBuzzProps (Array R.Element) => cpt -> Aff Unit
-- test cpt = do
-- test cpt = do
-- let context = R.createContext 0
-- let context = R.createContext 0
-- pure unit
-- pure unit
-- memoTest :: Spec Unit
-- callbackTest :: Spec Unit
-- imperativeHandleTest :: Spec Unit
-- debugValueTest :: Spec Unit
-- listTest :: Spec Unit
-- memoTest :: Spec
-- callbackTest :: Spec
-- imperativeHandleTest :: Spec
-- debugValueTest :: Spec
-- listTest :: Spec
-- listTest = pure unit
-- listTest = pure unit
spec :: Spec Unit
spec :: Spec
T Aff Unit Effect
Unit
spec = sequence_
spec = sequence_
[ staticTest
[ staticTest
, counterTest -- useState
, counterTest -- useState
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment