mirror of
https://github.com/Orasund/elm-ui-widgets.git
synced 2024-11-22 22:33:33 +03:00
83 lines
4.9 KiB
Elm
83 lines
4.9 KiB
Elm
|
module VerifyExamples.Widget.SortTableV20 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
|
||
|
= ChangedSorting String
|
||
|
| PressedButton String
|
||
|
|
||
|
asc : Bool
|
||
|
asc =
|
||
|
True
|
||
|
sortBy : String
|
||
|
sortBy =
|
||
|
"Id"
|
||
|
|
||
|
|
||
|
|
||
|
spec0 : Test.Test
|
||
|
spec0 =
|
||
|
Test.test "#sortTableV2: \n\n Widget.sortTableV2 (Material.sortTable Material.defaultPalette)\n { content =\n [ { id = 1, name = \"Antonio\", rating = 2.456, hash = Nothing }\n , { id = 2, name = \"Ana\", rating = 1.34, hash = Just \"45jf\" }\n , { id = 3, name = \"Alfred\", rating = 4.22, hash = Just \"6fs1\" }\n , { id = 4, name = \"Thomas\", rating = 3, hash = Just \"k52f\" }\n ]\n , columns =\n [ Widget.intColumnV2\n { title = \"Id\"\n , value = .id\n , toString = \\int -> \"#\" ++ String.fromInt int\n , width = Element.fill\n }\n , Widget.stringColumnV2\n { title = \"Name\"\n , value = .name\n , toString = identity\n , width = Element.fill\n }\n , Widget.floatColumnV2\n { title = \"Rating\"\n , value = .rating\n , toString = String.fromFloat\n , width = Element.fill\n }\n , Widget.customColumnV2\n { title = \"Action\"\n , value =\n \\{name} ->\n Widget.textButton\n (Material.textButton Material.defaultPalette)\n { text = name\n , onPress = Just <| PressedButton name\n }\n , width = Element.fill\n }\n , Widget.unsortableColumnV2\n { title = \"Hash\"\n , toString = (\\{hash} -> hash |> Maybe.withDefault \"None\")\n , width = Element.fill\n }\n ]\n , asc = asc\n , sortBy = sortBy\n , onChange = ChangedSorting\n }\n |> always \"Ignore this line\"\n --> \"Ignore this line\"" <|
|
||
|
\() ->
|
||
|
Expect.equal
|
||
|
(
|
||
|
Widget.sortTableV2 (Material.sortTable Material.defaultPalette)
|
||
|
{ content =
|
||
|
[ { id = 1, name = "Antonio", rating = 2.456, hash = Nothing }
|
||
|
, { id = 2, name = "Ana", rating = 1.34, hash = Just "45jf" }
|
||
|
, { id = 3, name = "Alfred", rating = 4.22, hash = Just "6fs1" }
|
||
|
, { id = 4, name = "Thomas", rating = 3, hash = Just "k52f" }
|
||
|
]
|
||
|
, columns =
|
||
|
[ Widget.intColumnV2
|
||
|
{ title = "Id"
|
||
|
, value = .id
|
||
|
, toString = \int -> "#" ++ String.fromInt int
|
||
|
, width = Element.fill
|
||
|
}
|
||
|
, Widget.stringColumnV2
|
||
|
{ title = "Name"
|
||
|
, value = .name
|
||
|
, toString = identity
|
||
|
, width = Element.fill
|
||
|
}
|
||
|
, Widget.floatColumnV2
|
||
|
{ title = "Rating"
|
||
|
, value = .rating
|
||
|
, toString = String.fromFloat
|
||
|
, width = Element.fill
|
||
|
}
|
||
|
, Widget.customColumnV2
|
||
|
{ title = "Action"
|
||
|
, value =
|
||
|
\{name} ->
|
||
|
Widget.textButton
|
||
|
(Material.textButton Material.defaultPalette)
|
||
|
{ text = name
|
||
|
, onPress = Just <| PressedButton name
|
||
|
}
|
||
|
, width = Element.fill
|
||
|
}
|
||
|
, Widget.unsortableColumnV2
|
||
|
{ title = "Hash"
|
||
|
, toString = (\{hash} -> hash |> Maybe.withDefault "None")
|
||
|
, width = Element.fill
|
||
|
}
|
||
|
]
|
||
|
, asc = asc
|
||
|
, sortBy = sortBy
|
||
|
, onChange = ChangedSorting
|
||
|
}
|
||
|
|> always "Ignore this line"
|
||
|
)
|
||
|
(
|
||
|
"Ignore this line"
|
||
|
)
|