Skip to content

Commit 52c1d92

Browse files
authored
Merge pull request #27 from Kocal/feature/ISSUE-2
Write tests
2 parents 28c4b5c + 9b61f70 commit 52c1d92

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
sudo: required
2+
dist: trusty
3+
4+
language: node_js
5+
6+
node_js:
7+
- "6"
8+
9+
env:
10+
- USE_AXIOS=true USE_ROUTER=true USE_VUEX=true
11+
- USE_AXIOS=false USE_ROUTER=false USE_VUEX=false
12+
13+
- USE_AXIOS=true USE_ROUTER=false USE_VUEX=false
14+
- USE_AXIOS=false USE_ROUTER=true USE_VUEX=false
15+
- USE_AXIOS=false USE_ROUTER=false USE_VUEX=true
16+
17+
before_install:
18+
# Remove the MongoDB repo as their GPG key has expired.
19+
- sudo rm /etc/apt/sources.list.d/mongodb-3.4.list
20+
# APT
21+
- sudo apt -qq update
22+
- sudo apt install -y expect
23+
# Yarn
24+
- curl -o- -L https://yarnpkg.com/install.sh | bash
25+
- export PATH="$HOME/.yarn/bin:$PATH"
26+
- yarn global add vue-cli
27+
28+
before_script:
29+
- cd tests
30+
- ./generate_extension.exp
31+
- cd output
32+
- yarn
33+
- yarn build
34+
- cd ..
35+
36+
script:
37+
- if [ $USE_AXIOS = "true" ]; then ./test_axios.sh; else echo "Will not testing Axios..."; fi;
38+
- if [ $USE_ROUTER = "true" ]; then ./test_router.sh; else echo "Will not testing Vue-Router..."; fi;
39+
- if [ $USE_VUEX = "true" ]; then ./test_store.sh; else echo "Will not testing Vuex..."; fi;

tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output/

tests/generate_extension.exp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/expect
2+
3+
spawn vue init kocal/vue-web-extension output
4+
5+
expect "Project name" { send "output\n"}
6+
expect "Project description" { send "The description of my wonderful extension\n" }
7+
expect "Author" { send "John Smith <john@smith.com>\n" }
8+
9+
set choice [expr $::env(USE_ROUTER) == true ? "y" : "n"]
10+
expect "Install vue-router?" { send "$choice\n" }
11+
12+
set choice [expr $::env(USE_VUEX) == true ? "y" : "n"]
13+
expect "Install vuex?" {send "$choice\n" }
14+
15+
set choice [expr $::env(USE_AXIOS) == true ? "y" : "n"]
16+
expect "Install axios?" { send "$choice\n" }
17+
18+
expect "vue-cli · Generated" { send "\n"}

tests/test_axios.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -ev
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
cd "$DIR/output"
7+
8+
echo "Checking Axios..."
9+
10+
if ! grep -q "axios" package.json; then
11+
echo "Axios not found in package.json"
12+
cat package.json
13+
exit 1
14+
fi;

tests/test_router.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -ev
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
cd "$DIR/output"
7+
8+
echo "Checking Vue-Router..."
9+
10+
if ! grep -q "vue-router" package.json; then
11+
echo "Vue-Router not found in package.json"
12+
cat packages.json
13+
exit 1
14+
fi;
15+
16+
test -f src/popup/router/pages/Index.vue
17+
test -f src/popup/router/index.js
18+
test -f src/popup/router/routes.js
19+
20+
if ! grep -ql "^import router from './router';$" src/popup/popup.js; then
21+
echo "Line « import router from './router'; » not found in src/popup/popup.js"
22+
cat src/popup/popup.js
23+
exit 2
24+
fi;
25+
26+
if ! grep -ql "^[[:space:]][[:space:]]router,$" src/popup/popup.js; then
27+
echo "Line « router, » not found in src/popup/popup.js"
28+
cat src/popup/popup.js
29+
exit 2
30+
fi;
31+

tests/test_store.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -ev
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
cd "$DIR/output"
7+
8+
echo "Checking Vuex..."
9+
10+
if ! grep -q "vuex" package.json; then
11+
echo "Vuex not found in package.json"
12+
cat packages.json
13+
exit 1
14+
fi;
15+
16+
test -f src/store/actions.js
17+
test -f src/store/getters.js
18+
test -f src/store/index.js
19+
test -f src/store/mutation-types.js
20+
test -f src/store/mutations.js
21+
22+
if ! grep -ql "^import store from './store';$" src/background.js; then
23+
echo "Line « import store from './store'; » not found in src/background.js"
24+
cat src/background.js
25+
exit 2
26+
fi;
27+
28+
if ! grep -ql "^import store from './../store';$" src/popup/popup.js; then
29+
echo "Line « import store from './../store'; » not found in src/popup/popup.js"
30+
cat src/popup/popup.js
31+
exit 2
32+
fi;
33+
34+
if ! grep -ql "^[[:space:]][[:space:]]store,$" src/popup/popup.js; then
35+
echo "Line « store, » not found in src/popup/popup.js"
36+
cat src/popup/popup.js
37+
exit 2
38+
fi;

0 commit comments

Comments
 (0)