diff --git a/.gitignore b/.gitignore index 38e1975447..75e8d77f52 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .DS_Store docs/_book test/ +tests/*/ diff --git a/circle.yml b/circle.yml index 8290c039d3..7157b38f99 100644 --- a/circle.yml +++ b/circle.yml @@ -6,7 +6,7 @@ dependencies: pre: - sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list' - sudo apt-get update - - sudo apt-get install google-chrome-stable + - sudo apt-get install -y google-chrome-stable expect test: override: diff --git a/test.sh b/test.sh index 5f0d4f119d..bf13744cfc 100755 --- a/test.sh +++ b/test.sh @@ -1,9 +1,16 @@ +#!/usr/bin/env bash + set -e -yes "" | ./node_modules/.bin/vue init . test +cd tests + +for f in *.sh; do + filename=$(basename "$f") + testname="${filename%.*}" + + source "$f" "$testname" +done + +cd .. + -cd test -npm install -npm run lint -npm test -npm run build diff --git a/tests/airbnb.expect b/tests/airbnb.expect new file mode 100644 index 0000000000..12e90fb738 --- /dev/null +++ b/tests/airbnb.expect @@ -0,0 +1,31 @@ +set testname [lindex $argv 0]; +spawn ../node_modules/.bin/vue init .. $testname + +expect "Project name" +send "\n" +expect "Project description" +send "\n" +expect "Author" +send "\n" +expect "Vue build" +send "\n" +expect "Install vue-router" +send "\n" +expect "ESLint" +send "\n" +expect "ESLint preset" +send "\[B" +expect "Airbnb" +send "\n" +expect "unit tests" +send "\n" +expect "test runner" +send "\n" +expect "e2e tests" +send "\n" +expect "npm install" +send "\[B" +send "\[B" +expect "No" +send "\n" +expect eof diff --git a/tests/airbnb.sh b/tests/airbnb.sh new file mode 100644 index 0000000000..9cca5d87a2 --- /dev/null +++ b/tests/airbnb.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +testname=$1 + +if [[ -z $testname ]]; then + echo "No test name given" + exit -1; +fi + +if [[ "$testname" == *\/* ]] || [[ "$testname" == *\\* ]]; then + echo "Invalid test name" + exit -1; +fi + +rm -Rf "$testname" + +expect "$testname.expect" "$testname" + +echo "Testing $testname" +cd $testname +npm install +npm run lint -- --fix +npm run lint +npm test +npm run build +cd .. diff --git a/tests/default.expect b/tests/default.expect new file mode 100644 index 0000000000..6f8d9171bb --- /dev/null +++ b/tests/default.expect @@ -0,0 +1,29 @@ +set testname [lindex $argv 0]; +spawn ../node_modules/.bin/vue init .. $testname + +expect "Project name" +send "\n" +expect "Project description" +send "\n" +expect "Author" +send "\n" +expect "Vue build" +send "\n" +expect "Install vue-router" +send "\n" +expect "ESLint" +send "\n" +expect "ESLint preset" +send "\n" +expect "unit tests" +send "\n" +expect "test runner" +send "\n" +expect "e2e tests" +send "\n" +expect "npm install" +send "\[B" +send "\[B" +expect "No" +send "\n" +expect eof diff --git a/tests/default.sh b/tests/default.sh new file mode 100644 index 0000000000..9cca5d87a2 --- /dev/null +++ b/tests/default.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +testname=$1 + +if [[ -z $testname ]]; then + echo "No test name given" + exit -1; +fi + +if [[ "$testname" == *\/* ]] || [[ "$testname" == *\\* ]]; then + echo "Invalid test name" + exit -1; +fi + +rm -Rf "$testname" + +expect "$testname.expect" "$testname" + +echo "Testing $testname" +cd $testname +npm install +npm run lint -- --fix +npm run lint +npm test +npm run build +cd .. diff --git a/tests/no-eslint-karma.expect b/tests/no-eslint-karma.expect new file mode 100644 index 0000000000..617547c5e7 --- /dev/null +++ b/tests/no-eslint-karma.expect @@ -0,0 +1,30 @@ +set testname [lindex $argv 0]; +spawn ../node_modules/.bin/vue init .. $testname + +expect "Project name" +send "\n" +expect "Project description" +send "\n" +expect "Author" +send "\n" +expect "Vue build" +send "\n" +expect "Install vue-router" +send "\n" +expect "ESLint" +send "n" +send "\n" +expect "unit tests" +send "\n" +expect "test runner" +send "\n" +expect "e2e tests" +send "\[B" +expect "Karma" +send "\n" +expect "npm install" +send "\[B" +send "\[B" +expect "No" +send "\n" +expect eof diff --git a/tests/no-eslint-karma.sh b/tests/no-eslint-karma.sh new file mode 100644 index 0000000000..37a8f2c067 --- /dev/null +++ b/tests/no-eslint-karma.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +testname=$1 + +if [[ -z $testname ]]; then + echo "No test name given" + exit -1; +fi + +if [[ "$testname" == *\/* ]] || [[ "$testname" == *\\* ]]; then + echo "Invalid test name" + exit -1; +fi + +rm -Rf "$testname" + +expect "$testname.expect" "$testname" + +echo "Testing $testname" +cd $testname +npm install +npm test +npm run build +cd .. diff --git a/tests/no-router.expect b/tests/no-router.expect new file mode 100644 index 0000000000..a341e7accc --- /dev/null +++ b/tests/no-router.expect @@ -0,0 +1,30 @@ +set testname [lindex $argv 0]; +spawn ../node_modules/.bin/vue init .. $testname + +expect "Project name" +send "\n" +expect "Project description" +send "\n" +expect "Author" +send "\n" +expect "Vue build" +send "\n" +expect "Install vue-router" +send "n" +send "\n" +expect "ESLint" +send "\n" +expect "ESLint preset" +send "\n" +expect "unit tests" +send "\n" +expect "test runner" +send "\n" +expect "e2e tests" +send "\n" +expect "npm install" +send "\[B" +send "\[B" +expect "No" +send "\n" +expect eof diff --git a/tests/no-router.sh b/tests/no-router.sh new file mode 100644 index 0000000000..9cca5d87a2 --- /dev/null +++ b/tests/no-router.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +testname=$1 + +if [[ -z $testname ]]; then + echo "No test name given" + exit -1; +fi + +if [[ "$testname" == *\/* ]] || [[ "$testname" == *\\* ]]; then + echo "Invalid test name" + exit -1; +fi + +rm -Rf "$testname" + +expect "$testname.expect" "$testname" + +echo "Testing $testname" +cd $testname +npm install +npm run lint -- --fix +npm run lint +npm test +npm run build +cd ..