mirror of
https://github.com/typeable/elm-ui.git
synced 2024-11-23 01:50:11 +03:00
Reorganize tests for easier running.
This commit is contained in:
parent
7e0d0b4fa0
commit
4765808458
@ -299,7 +299,7 @@ fromRgb255 clr =
|
||||
clr.alpha
|
||||
|
||||
|
||||
{-| Deconstruct a `Color` into it's rgb channels.
|
||||
{-| Deconstruct a `Color` into its rgb channels.
|
||||
-}
|
||||
toRgb :
|
||||
Color
|
||||
|
25
tests/README.md
Normal file
25
tests/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Elm UI Test Suite
|
||||
|
||||
There are two types of tests for Elm UI. The normal kind, which are located in `tests/suite/`
|
||||
|
||||
These can be run using [`elm-test`](https://github.com/elm-explorations/test) and can be run via
|
||||
|
||||
```bash
|
||||
elm-test
|
||||
```
|
||||
|
||||
at the `elm-ui` root.
|
||||
|
||||
# Layout Testing
|
||||
|
||||
`elm-ui` also needs to ensure that all layouts work as expected on all browsers.
|
||||
|
||||
In order to do this, we need a different testing environment.
|
||||
|
||||
So, the tests in `elm-ui/tests/Tests` will render output, then harvest bounding boxes form the browser, and run the test on the resulting data.
|
||||
|
||||
In order to run the test locally, compile
|
||||
|
||||
`elm make Tests/Run.elm --output elm.js`
|
||||
|
||||
and then open `gather-styles.html`
|
@ -1,12 +1,12 @@
|
||||
module Tests.Table exposing (..)
|
||||
module Tests.Table exposing (box, container, main, view)
|
||||
|
||||
import Tests.Palette as Palette exposing (..)
|
||||
import Html
|
||||
import Testable
|
||||
import Testable.Element as Element exposing (..)
|
||||
import Testable.Element.Background as Background
|
||||
import Testable.Element.Font as Font
|
||||
import Testable.Runner
|
||||
import Tests.Palette as Palette exposing (..)
|
||||
|
||||
|
||||
{-| -}
|
||||
@ -104,7 +104,7 @@ view =
|
||||
el [ Font.color white ] <|
|
||||
text "Index"
|
||||
, view =
|
||||
\i row -> el [ Background.color lightGrey, width fill ] <| text (toString i)
|
||||
\i row -> el [ Background.color lightGrey, width fill ] <| text (String.fromInt i)
|
||||
}
|
||||
, { header =
|
||||
el [ Font.color white ] <|
|
@ -1,4 +1,4 @@
|
||||
module Tests.Basic exposing (view)
|
||||
module Tests.WidthHeight exposing (view)
|
||||
|
||||
{-| -}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
port module Main exposing (..)
|
||||
port module FuzzMain exposing (Model, Msg(..), PossibleAttributes, Stage(..), Testable, TestableElement(..), allIndividualTestables, allPossibilities, analyze, attr, availableAttributes, content, createContainer, createElement, generateTest, generateTests, heightFill, heightPx, heights, init, layout, main, possibleToList, runTest, styles, subscriptions, testableLayout, tests, update, view, viewResult, widthFill, widthPx, widths)
|
||||
|
||||
{-| -}
|
||||
|
||||
@ -26,7 +26,8 @@ init : ( Model Msg, Cmd Msg )
|
||||
init =
|
||||
( { current = Nothing
|
||||
, upcoming =
|
||||
Tests.tests
|
||||
-- Tests.tests
|
||||
[]
|
||||
|
||||
-- generateTests (Random.initialSeed 227852860) 1
|
||||
, finished = []
|
||||
@ -93,6 +94,7 @@ generateTests : Random.Seed -> Int -> List (Testable msg)
|
||||
generateTests seed num =
|
||||
if num <= 0 then
|
||||
[]
|
||||
|
||||
else
|
||||
let
|
||||
( testable, newSeed ) =
|
||||
@ -225,6 +227,7 @@ view model =
|
||||
-- , Background.color Color.grey
|
||||
]
|
||||
(List.map viewResult model.finished)
|
||||
|
||||
else
|
||||
Html.text "running?"
|
||||
|
@ -1,8 +1,20 @@
|
||||
module Main exposing (..)
|
||||
module ClassNames exposing (suite)
|
||||
|
||||
{-| -}
|
||||
|
||||
import Expect
|
||||
import Html
|
||||
import Internal.Flag as Flag
|
||||
import Internal.Style
|
||||
import Test
|
||||
|
||||
|
||||
suite =
|
||||
Test.describe "Classname Collisions"
|
||||
[ Test.test "No duplicates" <|
|
||||
\_ ->
|
||||
Expect.equal [] onlyDuplicates
|
||||
]
|
||||
|
||||
|
||||
main =
|
||||
|
@ -1,49 +1,36 @@
|
||||
module Main exposing (allFlags, doesntInvalidateOthers, invalidateSelf, main)
|
||||
module Flags exposing (suite)
|
||||
|
||||
{-| -}
|
||||
|
||||
import Expect
|
||||
import Html
|
||||
import Internal.Flag as Flag
|
||||
import Test
|
||||
|
||||
|
||||
main =
|
||||
Html.div []
|
||||
[ Html.text "Verify All Flags invalidate themselves"
|
||||
, Html.div []
|
||||
(List.indexedMap invalidateSelf allFlags)
|
||||
, Html.text "Verify All Flags don't interfere with other flags"
|
||||
, Html.div []
|
||||
(List.indexedMap doesntInvalidateOthers allFlags)
|
||||
suite =
|
||||
Test.describe "Flag Operations"
|
||||
[ Test.test "All Flags Invalidate Themselves" <|
|
||||
\_ ->
|
||||
Expect.equal True (List.all (\flag -> Flag.present flag (Flag.add flag Flag.none)) allFlags)
|
||||
, Test.test "All Flags don't interfere with each other" <|
|
||||
\_ ->
|
||||
Expect.equal True (List.all (doesntInvalidateOthers allFlags) allFlags)
|
||||
]
|
||||
|
||||
|
||||
invalidateSelf i flag =
|
||||
if Flag.present flag (Flag.add flag Flag.none) then
|
||||
Html.text ""
|
||||
|
||||
else
|
||||
Html.div [] [ Html.text (toString (Flag.value flag) ++ " at index " ++ toString i ++ " does not invalidate itself") ]
|
||||
|
||||
|
||||
doesntInvalidateOthers i flag =
|
||||
doesntInvalidateOthers others flag =
|
||||
let
|
||||
withFlag =
|
||||
Flag.none
|
||||
|> Flag.add flag
|
||||
|
||||
passing =
|
||||
List.all identity <|
|
||||
List.indexedMap
|
||||
(\j otherFlag ->
|
||||
Flag.present otherFlag (Flag.add otherFlag withFlag)
|
||||
)
|
||||
allFlags
|
||||
in
|
||||
if passing then
|
||||
Html.text ""
|
||||
|
||||
else
|
||||
Html.div []
|
||||
[ Html.text (toString (Flag.value flag) ++ " at index " ++ toString i ++ " invalidates other flags!")
|
||||
]
|
||||
List.all identity <|
|
||||
List.map
|
||||
(\otherFlag ->
|
||||
Flag.present otherFlag (Flag.add otherFlag withFlag)
|
||||
)
|
||||
others
|
||||
|
||||
|
||||
allFlags =
|
||||
|
Loading…
Reference in New Issue
Block a user