Skip to content

Commit

Permalink
Merge pull request #2984 from openstreetmap/phantomjs-2
Browse files Browse the repository at this point in the history
Test with phantomjs 2.1 and mocha-phantomjs-core
  • Loading branch information
bhousel committed Feb 17, 2016
2 parents a908c67 + ac3dfb9 commit dd9e399
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
language: node_js
sudo: false
before_install:
# https://github.com/travis-ci/travis-ci/issues/3225
- mkdir travis-phantomjs
- wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
- export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
before_script: make
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ feel free to use newer features wisely.

Test your code and make sure it passes.

First ensure you have a `phantomjs` binary, version 2.0 or later, available on your `$PATH`. On a Mac,
you can install this via homebrew with `brew install phantomjs`. Then:

1. Go to the directory where you have checked out `iD`
2. run `npm install`
3. run `make`
Expand Down
2 changes: 1 addition & 1 deletion js/id/renderer/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ iD.Background = function(context) {
if (chosen && chosen.indexOf('custom:') === 0) {
background.baseLayerSource(iD.BackgroundSource.Custom(chosen.replace(/^custom:/, '')));
} else {
background.baseLayerSource(findSource(chosen) || best || findSource('Bing') || backgroundSources[1]);
background.baseLayerSource(findSource(chosen) || best || findSource('Bing') || backgroundSources[1] || backgroundSources[0]);
}

var locator = _.find(backgroundSources, function(d) {
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "test"
},
"scripts": {
"test": "eslint js/id && mocha-phantomjs test/index.html --ssl-protocol=tlsv1 && make && mocha-phantomjs test/index_packaged.html --ssl-protocol=tlsv1"
"test": "eslint js/id && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html dot && make && phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index_packaged.html dot"
},
"repository": {
"type": "git",
Expand All @@ -20,28 +20,28 @@
],
"license": "ISC",
"devDependencies": {
"chai": "~1.9.2",
"d3": "3.5.5",
"smash": "0.0",
"lodash-cli": "3.9.3",
"uglify-js": "~2.4.16",
"maki": "0.5.0",
"editor-imagery-index": "git://github.com/osmlab/editor-imagery-index.git#gh-pages",
"eslint": "~1.10.3",
"mocha": "~2.3.4",
"mocha-phantomjs": "~4.0.2",
"chai": "~1.9.2",
"sinon": "~1.6",
"sinon-chai": "~2.3.1",
"happen": "0.1.2",
"glob": "~3.1.21",
"happen": "0.1.2",
"js-yaml": "~3.3.1",
"request": "~2.16.2",
"jsonschema": "~0.3.2",
"editor-imagery-index": "git://github.com/osmlab/editor-imagery-index.git#gh-pages",
"name-suggestion-index": "0.1.1",
"lodash-cli": "3.9.3",
"maki": "0.5.0",
"minimist": "~1.2.0",
"mocha": "~2.3.4",
"mocha-phantomjs-core": "^1.3.0",
"name-suggestion-index": "0.1.1",
"request": "~2.16.2",
"sinon": "~1.6",
"sinon-chai": "~2.3.1",
"smash": "0.0",
"svg-sprite": "1.2.19",
"uglify-js": "~2.4.16",
"xml2js": "~0.4.13",
"xmlbuilder": "~4.2.0",
"svg-sprite": "1.2.19"
"xmlbuilder": "~4.2.0"
},
"engines": {
"node": ">=0.10.0"
Expand Down
8 changes: 7 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<script src="../node_modules/happen/src/happen.js"></script>
<script src="lib/bind-shim.js"></script>

<script>
if (typeof initMochaPhantomJS === 'function') {
initMochaPhantomJS()
}
</script>

<!-- include source files here... -->
<script src='../js/lib/lodash.js'></script>
<script src='../js/lib/d3.v3.js'></script>
Expand Down Expand Up @@ -327,7 +333,7 @@

<script>
iD.data.load('../', function() {
(window.mochaPhantomJS || window.mocha).run();
window.mocha.run();
});
</script>
</body>
Expand Down
8 changes: 7 additions & 1 deletion test/index_packaged.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<script src="../node_modules/happen/src/happen.js"></script>
<script src="lib/bind-shim.js"></script>

<script>
if (typeof initMochaPhantomJS === 'function') {
initMochaPhantomJS()
}
</script>

<!-- include source files here... -->
<script src='../dist/iD.js'></script>
<script src='../dist/presets.js'></script>
Expand Down Expand Up @@ -121,7 +127,7 @@
<script src="spec/id.js"></script>

<script>
(window.mochaPhantomJS || window.mocha).run();
window.mocha.run();
</script>
</body>
</html>
4 changes: 3 additions & 1 deletion test/spec/modes/add_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ describe("iD.modes.AddPoint", function() {

context = iD()
.presets(iD.data.presets)
.imagery(iD.data.imagery)
.imagery([])
.container(container);

context.loadTiles = function () {};

container.call(context.map())
.append('div')
.attr('class', 'inspector-wrap');
Expand Down

0 comments on commit dd9e399

Please sign in to comment.