Skip to content

Commit

Permalink
Login tests corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
orocancourt committed Mar 14, 2017
1 parent 9e0b29b commit 3bb7140
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/App/Views/Login/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ type alias Model =
, intro : String
, inputPlaceholder : String
, submitLabel : String
, requiredPath : String
}


Expand All @@ -16,5 +15,4 @@ defaultModel =
, intro = "Has autem provincias, quas Orontes ambiens amnis imosque pedes Cassii montis illius celsi praetermeans funditur in Parthenium mare, Gnaeus Pompeius superato Tigrane regnis Armeniorum abstractas dicioni Romanae coniunxit."
, inputPlaceholder = "Your username"
, submitLabel = "Login"
, requiredPath = "hola"
}
4 changes: 2 additions & 2 deletions src/App/Views/Login/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import Views.Login.Messages exposing (Msg(..))
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
ChangeLocation requiredPath ->
( { model | requiredPath = requiredPath }, Navigation.newUrl requiredPath )
ChangeLocation path ->
( model, Navigation.newUrl path )
5 changes: 1 addition & 4 deletions src/App/Views/Login/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Views.Login.View exposing (..)

import Html.CssHelpers
import Html exposing (Html, div, img, p, text, form, button, input, a)
import Html.Events exposing (onWithOptions)
import Html.Attributes exposing (src, href, type_, autocomplete, placeholder, autofocus)

import Css.AppCss exposing (CssClasses(..))
Expand All @@ -11,13 +10,11 @@ import Views.Login.Model exposing (Model)
import Views.Login.Messages exposing (Msg(..))
import Components.Link exposing (onLinkClick)


{ class } =
Html.CssHelpers.withNamespace "microblog"


-- VIEW


view : Model -> Html Msg
view model =
div [ class [ App ] ]
Expand Down
16 changes: 11 additions & 5 deletions tests/Views/LoginTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@ import Test exposing (..)
import Test.Html.Query as Query
import Test.Html.Selector exposing (..)

import Views.Login exposing (loginView, defaultLoginModel)
import Views.Login.View exposing (view)
import Views.Login.Model exposing (defaultModel)


all : Test
all =
let
loginComponent =
loginView defaultLoginModel
view defaultModel
|> Query.fromHtml
in
describe "view loginView"
[ test "Form should have correct image" <|
\() ->
loginComponent
|> Query.find [ tag "img" ]
|> Query.has [ attribute "src" "https://avatars0.githubusercontent.com/u/4359353?v=3&s=200" ]
|> Query.has [ attribute "src" defaultModel.logo ]
, test "Form should have correct intro" <|
\() ->
loginComponent
|> Query.find [ tag "p" ]
|> Query.has [ text "Has autem provincias, quas Orontes ambiens amnis imosque pedes Cassii montis illius celsi praetermeans funditur in Parthenium mare, Gnaeus Pompeius superato Tigrane regnis Armeniorum abstractas dicioni Romanae coniunxit." ]
|> Query.has [ text defaultModel.intro ]
, test "Form submit should have correct placeholder" <|
\() ->
loginComponent
|> Query.find [ tag "input" ]
|> Query.has [ attribute "placeholder" "Your username" ]
|> Query.has [ attribute "placeholder" defaultModel.inputPlaceholder ]
, test "Form submit should have correct submit label" <|
\() ->
loginComponent
|> Query.find [ tag "button" ]
|> Query.has [ text defaultModel.submitLabel]
]

0 comments on commit 3bb7140

Please sign in to comment.