set up scaffolding for js tests (#553)
This commit is contained in:
parent
2a3fa80540
commit
45adda93b1
8 changed files with 70 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,10 +5,10 @@
|
||||||
# git config --global core.excludesfile ~/.gitignore_global
|
# git config --global core.excludesfile ~/.gitignore_global
|
||||||
|
|
||||||
#assety stuff
|
#assety stuff
|
||||||
realtime/node_modules
|
|
||||||
public/assets
|
public/assets
|
||||||
public/metamaps_mobile
|
public/metamaps_mobile
|
||||||
vendor/
|
vendor/
|
||||||
|
node_modules
|
||||||
|
|
||||||
#secrets and config
|
#secrets and config
|
||||||
.env
|
.env
|
||||||
|
|
12
.travis.yml
12
.travis.yml
|
@ -1,9 +1,21 @@
|
||||||
sudo: false
|
sudo: false
|
||||||
language: ruby
|
language: ruby
|
||||||
|
cache:
|
||||||
|
bundler: true
|
||||||
|
directories:
|
||||||
|
- app/assets/javascripts/node_modules
|
||||||
rvm:
|
rvm:
|
||||||
- 2.1.3
|
- 2.1.3
|
||||||
before_script:
|
before_script:
|
||||||
|
- echo "Rspec setup"
|
||||||
- export RAILS_ENV=test
|
- export RAILS_ENV=test
|
||||||
- cp .example-env .env
|
- cp .example-env .env
|
||||||
- bundle exec rake db:create
|
- bundle exec rake db:create
|
||||||
- bundle exec rake db:schema:load
|
- bundle exec rake db:schema:load
|
||||||
|
- echo "node setup"
|
||||||
|
- . $HOME/.nvm/nvm.sh
|
||||||
|
- nvm install stable
|
||||||
|
- nvm use stable
|
||||||
|
- (cd app/assets/javascripts && npm install)
|
||||||
|
script:
|
||||||
|
- bundle exec rspec && (cd app/assets/javascripts && npm test)
|
||||||
|
|
9
app/assets/javascripts/README-testing-js.md
Normal file
9
app/assets/javascripts/README-testing-js.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Change directories to where this file is, and then run
|
||||||
|
|
||||||
|
npm install
|
||||||
|
|
||||||
|
to set up your testing environment. Then use
|
||||||
|
|
||||||
|
npm test
|
||||||
|
|
||||||
|
to see the results of testing the current javascript files.
|
22
app/assets/javascripts/package.json
Normal file
22
app/assets/javascripts/package.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "metamaps-frontend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Metamaps frontend - currently just tests",
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha test || echo 'Run `npm install` to setup testing'"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/metamaps/metamaps.git"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "AGPL-3.0",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/metamaps/metamaps/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/metamaps/metamaps#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"chai": "^3.5.0",
|
||||||
|
"mocha": "^2.4.5"
|
||||||
|
}
|
||||||
|
}
|
|
@ -320,3 +320,5 @@ Metamaps.Import = {
|
||||||
Metamaps.Synapse.renderSynapse(mapping, synapse, node1, node2, true)
|
Metamaps.Synapse.renderSynapse(mapping, synapse, node1, node2, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = Metamaps.Import
|
||||||
|
|
13
app/assets/javascripts/test/Metamaps.Import.spec.js
Normal file
13
app/assets/javascripts/test/Metamaps.Import.spec.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
var chai = require('chai')
|
||||||
|
var expect = chai.expect
|
||||||
|
|
||||||
|
Metamaps = {}
|
||||||
|
Metamaps.Import = require('../src/Metamaps.Import')
|
||||||
|
|
||||||
|
describe('Metamaps.Import.js', function() {
|
||||||
|
it('has a topic whitelist', function() {
|
||||||
|
expect(Metamaps.Import.topicWhitelist).to.deep.equal(
|
||||||
|
['id', 'name', 'metacode', 'x', 'y', 'description', 'link', 'permission']
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
|
@ -3,6 +3,7 @@
|
||||||
# jenkins machine prerequisites
|
# jenkins machine prerequisites
|
||||||
# sudo aptitude -q -y install libpq-dev
|
# sudo aptitude -q -y install libpq-dev
|
||||||
# install rvm with user gemsets
|
# install rvm with user gemsets
|
||||||
|
# install node and npm
|
||||||
|
|
||||||
source "$HOME/.rvm/scripts/rvm"
|
source "$HOME/.rvm/scripts/rvm"
|
||||||
rvm use $(cat .ruby-version) || \
|
rvm use $(cat .ruby-version) || \
|
||||||
|
@ -19,10 +20,15 @@ export RAILS_ENV=test
|
||||||
cp .example-env .env
|
cp .example-env .env
|
||||||
sed -i -e "s/DB_USERNAME='.*'/DB_USERNAME='jenkins'/" .env
|
sed -i -e "s/DB_USERNAME='.*'/DB_USERNAME='jenkins'/" .env
|
||||||
|
|
||||||
#test
|
# rspec tests
|
||||||
bundle install
|
bundle install
|
||||||
rake db:drop
|
rake db:drop
|
||||||
rake db:create
|
rake db:create
|
||||||
rake db:schema:load
|
rake db:schema:load
|
||||||
rake db:migrate
|
rake db:migrate
|
||||||
COVERAGE=on bundle exec rspec
|
COVERAGE=on bundle exec rspec
|
||||||
|
|
||||||
|
# javascript tests
|
||||||
|
cd app/assets/javascripts
|
||||||
|
npm install
|
||||||
|
npm test
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
## Testing Javascript
|
||||||
|
|
||||||
|
Javascript tests are under construction, but you can read more in the README in `app/assets/javascripts`.
|
||||||
|
|
||||||
## Testing with RSpec
|
## Testing with RSpec
|
||||||
|
|
||||||
RSpec is a ruby gem that allows you to test your code base. This is great -
|
RSpec is a ruby gem that allows you to test your code base. This is great -
|
||||||
|
|
Loading…
Reference in a new issue