<commit_before>module Tests exposing (..)

import Test exposing (..)
import Expect exposing (..)
import String
import Model
import Update
import Form exposing (Form)
import Form.Error exposing (..)
import Form.Field as Field


all : Test
all =
    describe "Initial example validation"
        [ test "has no output" <|
            \_ -> equal Nothing (Form.getOutput validatedForm)
        , test "has errors on expected fields" <|
            \_ ->
                equal
                    (Form.getErrors validatedForm)
                    [ ( "email", InvalidString )
                    , ( "profile.age", InvalidInt )
                    , ( "profile.role", InvalidString )
                    , ( "profile.superpower", InvalidString )
                    ]
        , test "set then get field in list" <|
            \_ ->
                let
                    ( name, value ) =
                        ( "links.0.name", "Twitter" )

                    newForm =
                        Form.update (Form.Input name (Field.Text value)) initialForm

                    maybeState =
                        Form.getFieldAsString name newForm
                in
                    equal (Just value) maybeState.value
        ]


initialForm : Form Model.CustomError Model.User
initialForm =
    Form.initial Model.initialFields Model.validate


validatedForm : Form Model.CustomError Model.User
validatedForm =
    Form.update Form.Validate initialForm<commit_msg>fix list test, append msg was missing<commit_after>module Tests exposing (..)

import Test exposing (..)
import Expect exposing (..)
import String
import Model
import Update
import Form exposing (Form)
import Form.Error exposing (..)
import Form.Field as Field


all : Test
all =
    describe "Initial example validation"
        [ test "has no output" <|
            \_ -> equal Nothing (Form.getOutput validatedForm)
        , test "has errors on expected fields" <|
            \_ ->
                equal
                    (Form.getErrors validatedForm)
                    [ ( "email", InvalidString )
                    , ( "profile.age", InvalidInt )
                    , ( "profile.role", InvalidString )
                    , ( "profile.superpower", InvalidString )
                    ]
        , test "append, set then get field in list" <|
            \_ ->
                let
                    ( name, value ) =
                        ( "links.0.name", "Twitter" )

                    formAfterAppend =
                        Form.update (Form.Append "links") initialForm

                    formAfterInput =
                        Form.update (Form.Input name (Field.Text value)) formAfterAppend

                    maybeState =
                        Form.getFieldAsString name formAfterInput
                in
                    equal (Just value) maybeState.value
        ]


initialForm : Form Model.CustomError Model.User
initialForm =
    Form.initial Model.initialFields Model.validate


validatedForm : Form Model.CustomError Model.User
validatedForm =
    Form.update Form.Validate initialForm
{'fraction_non_alphanumeric': 0.08341384863123993, 'fraction_numerical': 0.0006441223832528181, 'mean_word_length': 1.5028203062046737, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1824146', 'n_tokens_mistral': 778, 'n_tokens_neox': 712, 'n_words': 215}