diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..aee9810 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +/elm-stuff/ diff --git a/tests/Main.elm b/tests/Main.elm new file mode 100644 index 0000000..7d62c1a --- /dev/null +++ b/tests/Main.elm @@ -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 diff --git a/tests/Tests.elm b/tests/Tests.elm new file mode 100644 index 0000000..f31f173 --- /dev/null +++ b/tests/Tests.elm @@ -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) + ] + ] diff --git a/tests/elm-package.json b/tests/elm-package.json new file mode 100644 index 0000000..e27c7df --- /dev/null +++ b/tests/elm-package.json @@ -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" +}