Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnScottUK committed Sep 23, 2021
1 parent a03c4b4 commit fe540f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "test/shunit2"]
path = test/shunit2
url = https://github.com/kward/shunit2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 23 additions & 0 deletions test/jpp.test.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/shunit2
Submodule shunit2 added at 95cd60

0 comments on commit fe540f0

Please sign in to comment.