Skip to content

Instantly share code, notes, and snippets.

module Tests exposing (..)
import Test exposing (..)
import Expect exposing (..)
import Fuzz exposing (list, int, tuple, string)
import String
import ElmTestBDDStyle exposing (..)
all : Test
module Example where
import ElmTestBDDStyle exposing (..)
import Check.Producer exposing (..)
tests : Test
tests =
describe "A Test Suite"
[ it "adds two numbers" <|
expect (3 + 7) toBe 10
type alias Model =
{ tasks : List Task
, field : String
, uid : Int
, visibility : String
}
type alias Task =
{ description : String
, completed : Bool
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
NoOp ->
model ! []
Add ->
{ model
| uid = model.uid + 1
, field = ""
type alias Task =
{ description : String
, completed : Bool
, editing : Bool
, id : Int
}
type alias TaskList =
List Task
type Msg
= NoOp
| UpdateField String
| EditingTask Int Bool
| UpdateTask Int String
| Add
| Delete Int
| DeleteComplete
| Check Int Bool
| CheckAll Bool
type TaskMsg
= Check Bool
| Editing Bool
| Update String
type TaskListMsg
= Add Int String
| Delete Int
| DeleteComplete
| CheckAll Bool
update : Action -> Control -> Control
update actionFor control =
case actionFor of
ActionForControl action -> updateControl action control
_ -> control
updateControl : ControlAction -> Control -> Control
updateControl action model =
case action of
ChangeVisibility visibility ->
update : Msg -> Model -> Model
update msgFor taskList =
case msgFor of
MsgForTaskList msg ->
updateTaskList msg taskList
MsgForTask id msg ->
updateTask id msg taskList
_ ->
update : Msg -> Model -> Model
update msg model =
{ model
| taskEntry = Task.update msg model.taskEntry
, taskList = TaskList.update msg model.taskList
, control = Control.update msg model.control
}