Added Tests

This commit is contained in:
Lucas Payr 2021-01-26 22:12:35 +01:00
parent 1933b81b59
commit 777d29cf9f
15 changed files with 559 additions and 16 deletions

View File

@ -1 +1 @@
elm-verify-examples --run-tests
elm-verify-examples && elm-test

View File

@ -6,10 +6,10 @@
"version": "2.3.0",
"exposed-modules": [
"Widget",
"Widget.Style.Material",
"Widget.Style.Material.Typography",
"Widget.Style.Material.Color",
"Widget.Style.Customize",
"Widget.Material",
"Widget.Material.Typography",
"Widget.Material.Color",
"Widget.Customize",
"Widget.Layout",
"Widget.ScrollingNav",
"Widget.Snackbar",
@ -20,7 +20,7 @@
"Orasund/elm-ui-framework": "1.6.1 <= v < 2.0.0",
"avh4/elm-color": "1.0.0 <= v < 2.0.0",
"elm/browser": "1.0.2 <= v < 2.0.0",
"elm/core": "1.0.0 <= v < 2.0.0",
"elm/core": "1.0.2 <= v < 2.0.0",
"elm/html": "1.0.0 <= v < 2.0.0",
"elm/svg": "1.0.1 <= v < 2.0.0",
"elm/time": "1.0.0 <= v < 2.0.0",
@ -31,6 +31,7 @@
"wernerdegroot/listzipper": "4.0.0 <= v < 5.0.0"
},
"test-dependencies": {
"elm-explorations/test": "1.2.1 <= v < 2.0.0"
"elm-explorations/test": "1.2.1 <= v < 2.0.0",
"icidasset/elm-material-icons": "5.0.0 <= v < 6.0.0"
}
}

View File

@ -48,4 +48,4 @@
"elm/random": "1.0.0"
}
}
}
}

View File

@ -0,0 +1,4 @@
{
"root": "../src",
"tests": []
}

View File

@ -231,16 +231,20 @@ type alias TextButton msg =
{-| A button containing only an icon, the text is used for screenreaders.
import Widget.Style.Material as Material
import Widget.Material as Material
import Material.Icons as MaterialIcons
import Material.Icons.Types exposing (Coloring(..))
import Widget.Icon as Icon
type Msg
= Like
= Like
iconButton (Material.iconButton Material.defaultPalette)
{ text = Like
, icon = MaterialIcons.hearth |> Icon.elmMaterialIcons Color
{ text = "Like"
, icon = MaterialIcons.favorite |> Icon.elmMaterialIcons Color
, onPress = Just Like
}
|> always "Ignore this line" --> "Ignore this line"
-}
iconButton :
@ -261,6 +265,19 @@ iconButton =
{-| A button with just text and not icon.
import Widget.Material as Material
import Material.Icons as MaterialIcons
type Msg
= Like
textButton (Material.textButton Material.defaultPalette)
{ text = "Like"
, onPress = Just Like
}
|> always "Ignore this line" --> "Ignore this line"
-}
textButton :
ButtonStyle msg
@ -283,6 +300,22 @@ textButton style { text, onPress } =
{-| A button containing a text and an icon.
import Widget.Material as Material
import Material.Icons as MaterialIcons
import Material.Icons.Types exposing (Coloring(..))
import Widget.Icon as Icon
type Msg
= Submit
button (Material.containedButton Material.defaultPalette)
{ text = "Submit"
, icon = MaterialIcons.favorite |> Icon.elmMaterialIcons Color
, onPress = Just Submit
}
|> always "Ignore this line" --> "Ignore this line"
-}
button :
ButtonStyle msg
@ -341,6 +374,20 @@ type alias Switch msg =
{-| A boolean switch
import Widget.Material as Material
import Material.Icons as MaterialIcons
type Msg
= Activate
switch (Material.switch Material.defaultPalette)
{ description = "Activate Dark Mode"
, onPress = Just Activate
, active = False
}
|> always "Ignore this line" --> "Ignore this line"
-}
switch :
SwitchStyle msg
@ -402,6 +449,32 @@ type alias MultiSelect msg =
{-| A simple button that can be selected.
import Widget.Material as Material
import Material.Icons as MaterialIcons
import Element
type Msg
= ChangedSelected Int
{ selected = Just 1
, options =
[ 1, 2, 42 ]
|> List.map
(\int ->
{ text = String.fromInt int
, icon = always Element.none
}
)
, onSelect = (\i -> Just <| ChangedSelected i)
}
|> Widget.select
|> Widget.buttonRow
{ elementRow = Material.buttonRow
, content = Material.toggleButton Material.defaultPalette
}
|> always "Ignore this line" --> "Ignore this line"
-}
selectButton :
ButtonStyle msg
@ -412,6 +485,32 @@ selectButton =
{-| Selects one out of multiple options. This can be used for radio buttons or Menus.
import Widget.Material as Material
import Material.Icons as MaterialIcons
import Element
type Msg
= ChangedSelected Int
{ selected = Just 1
, options =
[ 1, 2, 42 ]
|> List.map
(\int ->
{ text = String.fromInt int
, icon = always Element.none
}
)
, onSelect = (\i -> Just <| ChangedSelected i)
}
|> Widget.select
|> Widget.buttonRow
{ elementRow = Material.buttonRow
, content = Material.toggleButton Material.defaultPalette
}
|> always "Ignore this line" --> "Ignore this line"
-}
select :
Select msg
@ -421,6 +520,33 @@ select =
{-| Selects multible options. This can be used for checkboxes.
import Widget.Material as Material
import Material.Icons as MaterialIcons
import Set
import Element
type Msg
= ChangedSelected Int
{ selected = [1,2] |> Set.fromList
, options =
[ 1, 2, 42 ]
|> List.map
(\int ->
{ text = String.fromInt int
, icon = always Element.none
}
)
, onSelect = (\i -> Just <| ChangedSelected i)
}
|> Widget.multiSelect
|> Widget.buttonRow
{ elementRow = Material.buttonRow
, content = Material.toggleButton Material.defaultPalette
}
|> always "Ignore this line" --> "Ignore this line"
-}
multiSelect :
MultiSelect msg
@ -468,6 +594,22 @@ type alias Dialog msg =
{-| A modal.
import Widget.Material as Material
import Element
type Msg
= Submit
| Close
Element.layout
(modal
{ onDismiss = Just Close
, content =
Element.text "Click outside this window to close it."
}
)
|> always "Ignore this line" --> "Ignore this line"
Technical Remark:
- To stop the screen from scrolling, set the height of the layout to the height of the screen.
@ -479,6 +621,32 @@ modal =
{-| A Dialog Window.
import Widget.Material as Material
import Element
type Msg
= Submit
| Close
Element.layout
(dialog (Material.alertDialog Material.defaultPalette)
{ title = Just "Accept"
, text = "Are you sure?"
, accept =
{ text = "Accept"
, onPress = Just Submit
}
|> Just
, dismiss =
{ text = "Cancel"
, onPress = Just Close
}
|> Just
}
)
|> always "Ignore this line" --> "Ignore this line"
-}
dialog :
DialogStyle msg

View File

@ -0,0 +1,37 @@
module VerifyExamples.Widget.Button0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Widget.Icon as Icon
import Material.Icons.Types exposing (Coloring(..))
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= Submit
spec0 : Test.Test
spec0 =
Test.test "#button: \n\n button (Material.containedButton Material.defaultPalette)\n { text = \"Submit\"\n , icon = MaterialIcons.favorite |> Icon.elmMaterialIcons Color\n , onPress = Just Submit\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
button (Material.containedButton Material.defaultPalette)
{ text = "Submit"
, icon = MaterialIcons.favorite |> Icon.elmMaterialIcons Color
, onPress = Just Submit
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,47 @@
module VerifyExamples.Widget.Dialog0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Element
import Widget.Material as Material
type Msg
= Submit
| Close
spec0 : Test.Test
spec0 =
Test.test "#dialog: \n\n Element.layout\n (dialog (Material.alertDialog Material.defaultPalette)\n { title = Just \"Accept\"\n , text = \"Are you sure?\"\n , accept =\n { text = \"Accept\"\n , onPress = Just Submit\n }\n |> Just\n , dismiss =\n { text = \"Cancel\"\n , onPress = Just Close\n }\n |> Just\n }\n )\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
Element.layout
(dialog (Material.alertDialog Material.defaultPalette)
{ title = Just "Accept"
, text = "Are you sure?"
, accept =
{ text = "Accept"
, onPress = Just Submit
}
|> Just
, dismiss =
{ text = "Cancel"
, onPress = Just Close
}
|> Just
}
)
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,37 @@
module VerifyExamples.Widget.IconButton0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Widget.Icon as Icon
import Material.Icons.Types exposing (Coloring(..))
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= Like
spec0 : Test.Test
spec0 =
Test.test "#iconButton: \n\n iconButton (Material.iconButton Material.defaultPalette)\n { text = \"Like\"\n , icon = MaterialIcons.favorite |> Icon.elmMaterialIcons Color\n , onPress = Just Like\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
iconButton (Material.iconButton Material.defaultPalette)
{ text = "Like"
, icon = MaterialIcons.favorite |> Icon.elmMaterialIcons Color
, onPress = Just Like
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,38 @@
module VerifyExamples.Widget.Modal0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Element
import Widget.Material as Material
type Msg
= Submit
| Close
spec0 : Test.Test
spec0 =
Test.test "#modal: \n\n Element.layout\n (modal\n { onDismiss = Just Close\n , content =\n Element.text \"Click outside this window to close it.\"\n }\n )\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
Element.layout
(modal
{ onDismiss = Just Close
, content =
Element.text "Click outside this window to close it."
}
)
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,48 @@
module VerifyExamples.Widget.MultiSelect0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Element
import Set
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= ChangedSelected Int
spec0 : Test.Test
spec0 =
Test.test "#multiSelect: \n\n { selected = [1,2] |> Set.fromList\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just <| ChangedSelected i)\n }\n |> Widget.multiSelect\n |> Widget.buttonRow\n { elementRow = Material.buttonRow\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
{ selected = [1,2] |> Set.fromList
, options =
[ 1, 2, 42 ]
|> List.map
(\int ->
{ text = String.fromInt int
, icon = always Element.none
}
)
, onSelect = (\i -> Just <| ChangedSelected i)
}
|> Widget.multiSelect
|> Widget.buttonRow
{ elementRow = Material.buttonRow
, content = Material.toggleButton Material.defaultPalette
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,47 @@
module VerifyExamples.Widget.Select0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Element
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= ChangedSelected Int
spec0 : Test.Test
spec0 =
Test.test "#select: \n\n { selected = Just 1\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just <| ChangedSelected i)\n }\n |> Widget.select\n |> Widget.buttonRow\n { elementRow = Material.buttonRow\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
{ selected = Just 1
, options =
[ 1, 2, 42 ]
|> List.map
(\int ->
{ text = String.fromInt int
, icon = always Element.none
}
)
, onSelect = (\i -> Just <| ChangedSelected i)
}
|> Widget.select
|> Widget.buttonRow
{ elementRow = Material.buttonRow
, content = Material.toggleButton Material.defaultPalette
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,47 @@
module VerifyExamples.Widget.SelectButton0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Element
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= ChangedSelected Int
spec0 : Test.Test
spec0 =
Test.test "#selectButton: \n\n { selected = Just 1\n , options =\n [ 1, 2, 42 ]\n |> List.map\n (\\int ->\n { text = String.fromInt int\n , icon = always Element.none\n }\n )\n , onSelect = (\\i -> Just <| ChangedSelected i)\n }\n |> Widget.select\n |> Widget.buttonRow\n { elementRow = Material.buttonRow\n , content = Material.toggleButton Material.defaultPalette\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
{ selected = Just 1
, options =
[ 1, 2, 42 ]
|> List.map
(\int ->
{ text = String.fromInt int
, icon = always Element.none
}
)
, onSelect = (\i -> Just <| ChangedSelected i)
}
|> Widget.select
|> Widget.buttonRow
{ elementRow = Material.buttonRow
, content = Material.toggleButton Material.defaultPalette
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,35 @@
module VerifyExamples.Widget.Switch0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= Activate
spec0 : Test.Test
spec0 =
Test.test "#switch: \n\n switch (Material.switch Material.defaultPalette)\n { description = \"Activate Dark Mode\"\n , onPress = Just Activate\n , active = False\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
switch (Material.switch Material.defaultPalette)
{ description = "Activate Dark Mode"
, onPress = Just Activate
, active = False
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -0,0 +1,34 @@
module VerifyExamples.Widget.TextButton0 exposing (..)
-- This file got generated by [elm-verify-examples](https://github.com/stoeffel/elm-verify-examples).
-- Please don't modify this file by hand!
import Test
import Expect
import Widget exposing (..)
import Material.Icons as MaterialIcons
import Widget.Material as Material
type Msg
= Like
spec0 : Test.Test
spec0 =
Test.test "#textButton: \n\n textButton (Material.textButton Material.defaultPalette)\n { text = \"Like\"\n , onPress = Just Like\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
\() ->
Expect.equal
(
textButton (Material.textButton Material.defaultPalette)
{ text = "Like"
, onPress = Just Like
}
|> always "Ignore this line"
)
(
"Ignore this line"
)

View File

@ -2,10 +2,10 @@
"root": "../src",
"tests": [
"Widget",
"Widget.Style.Material",
"Widget.Style.Material.Typography",
"Widget.Style.Material.Color",
"Widget.Style.Customize",
"Widget.Material",
"Widget.Material.Typography",
"Widget.Material.Color",
"Widget.Customize",
"Widget.Layout",
"Widget.ScrollingNav",
"Widget.Snackbar",