diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ad7a8e7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test/shunit2"] + path = test/shunit2 + url = https://github.com/kward/shunit2 diff --git a/package.json b/package.json index 1979e3a..f17cab7 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Command-Line Interface for the jsonpath-plus library", "main": "bin/jpp", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "test/jpp.test.sh" }, "author": "John Scott", "license": "ISC", diff --git a/test/jpp.test.sh b/test/jpp.test.sh new file mode 100755 index 0000000..3b818b6 --- /dev/null +++ b/test/jpp.test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +test="$(dirname $0)" +jpp="$test/../bin/jpp" + +testBasic() { + result=$($jpp "$test/openapi.json" '$'|wc -l) + assertEquals $result 1 +} + +testPretty() { + count=$(cat $test/openapi.json|wc -l) + result=$($jpp --pretty "$test/openapi.json" '$'|wc -l) + assertEquals $result $((count +2)) +} + +testSeparate() { + result=$($jpp --separate --jsonpath '$.paths[?(@.get && @.get.parameters)]~' $test/openapi.json|wc -l) + + assertEquals $result 7 +} + +# Load shUnit2. +. $test/shunit2/shunit2 diff --git a/test/shunit2 b/test/shunit2 new file mode 160000 index 0000000..95cd60d --- /dev/null +++ b/test/shunit2 @@ -0,0 +1 @@ +Subproject commit 95cd60d630090eba611c1b4bd0617d67a66abc5f