Initialized tests for app.
This commit is contained in:
parent
b02a3b1473
commit
dd5c07cc95
4 changed files with 71 additions and 0 deletions
1
tests/.gitignore
vendored
Normal file
1
tests/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/elm-stuff/
|
13
tests/Main.elm
Normal file
13
tests/Main.elm
Normal file
|
@ -0,0 +1,13 @@
|
|||
port module Main exposing (..)
|
||||
|
||||
import Tests
|
||||
import Test.Runner.Node exposing (run, TestProgram)
|
||||
import Json.Encode exposing (Value)
|
||||
|
||||
|
||||
main : TestProgram
|
||||
main =
|
||||
run emit Tests.all
|
||||
|
||||
|
||||
port emit : ( String, Value ) -> Cmd msg
|
37
tests/Tests.elm
Normal file
37
tests/Tests.elm
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Tests exposing (..)
|
||||
|
||||
import Test exposing (..)
|
||||
import Expect
|
||||
import Fuzz exposing (list, int, tuple, string)
|
||||
import String
|
||||
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "Sample Test Suite"
|
||||
[ describe "Unit test examples"
|
||||
[ test "Addition" <|
|
||||
\() ->
|
||||
Expect.equal (3 + 7) 10
|
||||
, test "String.left" <|
|
||||
\() ->
|
||||
Expect.equal "a" (String.left 1 "abcdefg")
|
||||
, test "This test should fail - you should remove it" <|
|
||||
\() ->
|
||||
Expect.fail "Failed as expected!"
|
||||
]
|
||||
, describe "Fuzz test examples, using randomly generated input"
|
||||
[ fuzz (list int) "Lists always have positive length" <|
|
||||
\aList ->
|
||||
List.length aList |> Expect.atLeast 0
|
||||
, fuzz (list int) "Sorting a list does not change its length" <|
|
||||
\aList ->
|
||||
List.sort aList |> List.length |> Expect.equal (List.length aList)
|
||||
, fuzzWith { runs = 1000 } int "List.member will find an integer in a list containing it" <|
|
||||
\i ->
|
||||
List.member i [ i ] |> Expect.true "If you see this, List.member returned False!"
|
||||
, fuzz2 string string "The length of a string equals the sum of its substrings' lengths" <|
|
||||
\s1 s2 ->
|
||||
s1 ++ s2 |> String.length |> Expect.equal (String.length s1 + String.length s2)
|
||||
]
|
||||
]
|
20
tests/elm-package.json
Normal file
20
tests/elm-package.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": "1.0.0",
|
||||
"summary": "Sample Elm Test",
|
||||
"repository": "https://github.com/user/project.git",
|
||||
"license": "BSD-3-Clause",
|
||||
"source-directories": [
|
||||
".",
|
||||
"../src"
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"elm-community/json-extra": "1.0.0 <= v < 2.0.0",
|
||||
"elm-lang/html": "1.0.0 <= v < 2.0.0",
|
||||
"mgold/elm-random-pcg": "3.0.0 <= v < 4.0.0",
|
||||
"elm-lang/core": "5.0.0 <= v < 6.0.0",
|
||||
"elm-community/elm-test": "3.0.0 <= v < 4.0.0",
|
||||
"rtfeldman/node-test-runner": "3.0.0 <= v < 4.0.0"
|
||||
},
|
||||
"elm-version": "0.18.0 <= v < 0.19.0"
|
||||
}
|
Loading…
Reference in a new issue