Sha256: 71c06c210e6c4612ea87faddc10970d5e1e6c08d4c6afc5a1c86a4a5e26d26cb

Contents?: true

Size: 1.75 KB

Versions: 38

Compression:

Stored size: 1.75 KB

Contents

port module Main exposing (..)

import Test.Runner.Node exposing (run)
import Json.Encode exposing (Value)
import Test exposing (..)
import Expect
import PhoneNumber exposing (getNumber, prettyPrint)


tests : Test
tests =
    describe "PhoneNumber"
        [ test "cleans number" <|
            \() -> Expect.equal (Just "1234567890") (getNumber "(123) 456-7890")
        , test "cleans number with dots" <|
            \() -> Expect.equal (Just "1234567890") (getNumber "123.456.7890")
        , test "valid when 11 digits and first is 1" <|
            \() -> Expect.equal (Just "1234567890") (getNumber "11234567890")
        , test "invalid when 11 digits" <|
            \() -> Expect.equal Nothing (getNumber "21234567890")
        , test "invalid when 9 digits" <|
            \() -> Expect.equal Nothing (getNumber "123456789")
        , test "invalid when 12 digits" <|
            \() -> Expect.equal Nothing (getNumber "123456789012")
        , test "invalid when empty" <|
            \() -> Expect.equal Nothing (getNumber "")
        , test "invalid when no digits present" <|
            \() -> Expect.equal Nothing (getNumber " (-) ")
        , test "valid with leading characters" <|
            \() -> Expect.equal (Just "1234567890") (getNumber "my number is 123 456 7890")
        , test "valid with trailing characters" <|
            \() -> Expect.equal (Just "1234567890") (getNumber "123 456 7890 - bob")
        , test "pretty print" <|
            \() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "1234567890")
        , test "pretty print with full us phone number" <|
            \() -> Expect.equal (Just "(123) 456-7890") (prettyPrint "11234567890")
        ]


main : Program Value
main =
    run emit tests


port emit : ( String, Value ) -> Cmd msg

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
trackler-2.0.5.1 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.5.0 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.4.0 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.9 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.8 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.7 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.6 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.5 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.4 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.3 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.2 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.1 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.3.0 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.2.0 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.1.2 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.1.1 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.1.0 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.0.10 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.0.9 tracks/elm/exercises/phone-number/PhoneNumberTests.elm
trackler-2.0.0.8 tracks/elm/exercises/phone-number/PhoneNumberTests.elm