Skip to content

Commit

Permalink
add one more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusfpleite committed Jul 16, 2024
1 parent e4a496d commit f30ef0f
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions tests/Install/InitializerTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ all =
, Run.testFix test2
, Run.testFix test3
, Run.testFix test4
, Run.testFix test5
]


Expand Down Expand Up @@ -280,3 +281,113 @@ init =
}
, Cmd.none
)"""


test5 =
{ description = "should insert multiple fields in a function with multiple arguments 2"
, src = src5
, rule = rule5
, under = under5
, fixed = fixed5
, message = "Add fields to the model"
}


src5 =
"""module Backend exposing (..)
import Html
import Lamdera exposing (ClientId, SessionId)
import Types exposing (..)
type alias Model =
BackendModel
app =
Lamdera.backend
{ init = init
, update = update
, updateFromFrontend = updateFromFrontend
, subscriptions = \\m -> Sub.none
}
init : ( Model, Cmd BackendMsg )
init =
( { message = "Hello!" }
, Cmd.none
)
update : BackendMsg -> Model -> ( Model, Cmd BackendMsg )
update msg model =
case msg of
NoOpBackendMsg ->
( model, Cmd.none )
updateFromFrontend : SessionId -> ClientId -> ToBackend -> Model -> ( Model, Cmd BackendMsg )
updateFromFrontend sessionId clientId msg model =
case msg of
NoOpToBackend ->
( model, Cmd.none )"""


rule5 =
Install.Initializer.makeRule "Backend"
"init"
[ { field = "pendingAuths", value = "Dict.empty" }
, { field = "sessions", value = "Dict.empty" }
, { field = "users", value = "Dict.empty" }
]


under5 =
"""init =
( { message = "Hello!" }
, Cmd.none
)"""


fixed5 =
"""module Backend exposing (..)
import Html
import Lamdera exposing (ClientId, SessionId)
import Types exposing (..)
type alias Model =
BackendModel
app =
Lamdera.backend
{ init = init
, update = update
, updateFromFrontend = updateFromFrontend
, subscriptions = \\m -> Sub.none
}
init : ( Model, Cmd BackendMsg )
init =
( { message = "Hello!", pendingAuths = Dict.empty, sessions = Dict.empty, users = Dict.empty }
, Cmd.none
)
update : BackendMsg -> Model -> ( Model, Cmd BackendMsg )
update msg model =
case msg of
NoOpBackendMsg ->
( model, Cmd.none )
updateFromFrontend : SessionId -> ClientId -> ToBackend -> Model -> ( Model, Cmd BackendMsg )
updateFromFrontend sessionId clientId msg model =
case msg of
NoOpToBackend ->
( model, Cmd.none )"""

0 comments on commit f30ef0f

Please sign in to comment.