Commit bd79196c authored by Cédric F.'s avatar Cédric F.

Set up tests

parent 7dbccc08
elm-stuff/ elm-stuff/
/public/elm.js /public/elm.min.js
image: node:latest
cache:
paths:
- elm-stuff
before_script:
- npm install -g elm
- npm install -g uglify-js
- elm --version
- elm-package install --yes
build:
script: make
test:
script: make test
...@@ -2,9 +2,11 @@ all: trappisto ...@@ -2,9 +2,11 @@ all: trappisto
trappisto: src/*.elm trappisto: src/*.elm
elm-make src/Trappisto.elm --warn --output public/elm.js elm-make src/Trappisto.elm --warn --output public/elm.js
uglifyjs --mangle --screw-ie8 --output public/elm.min.js -- public/elm.js
rm public/elm.js
test: all test: src/*.elm tests/*.elm
elm-test # TODO elm-test
nginx: nginx/nginx.conf nginx: nginx/nginx.conf
nginx -c nginx/nginx.conf -p . -g 'daemon off;' nginx -c nginx/nginx.conf -p . -g 'daemon off;'
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<script src="elm.js" async defer></script> <script src="elm.min.js" async defer></script>
<style> <style>
/* inconsolata-regular - latin */ /* inconsolata-regular - latin */
......
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
module Tests exposing (..)
import Test exposing (..)
import Expect
import Fuzz exposing (list, int, tuple, string)
import String
import Json.Decode as Decode
import Components.Block as Block
all : Test
all =
describe "Sample Test Suite"
[ describe "Unit test examples"
[ test "decodeGetBlockHash" <|
\() ->
Expect.equal (Ok "deadbeef") <| Decode.decodeString Block.decodeGetBlockHash "{\"result\":\"deadbeef\"}"
]
, describe "Fuzz test examples, using randomly generated input"
-- XXX: keping them as examples
[ 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)
]
]
{
"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": {
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
"elm-community/json-extra": "2.0.0 <= v < 3.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/http": "1.0.0 <= v < 2.0.0",
"mgold/elm-random-pcg": "4.0.2 <= v < 5.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"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment