camptocamp/ngeo — pull request #19 by elemoine (2014-06-23 16:04:47+00:00)
Title: Add some checks for ngeo.js

This PR adds a `check-examples` target to the Makefile. This target runs non-compiled versions of the examples in Phantomjs. The goal is to verify that ngeo.js, the standalone version of ngeo, works as expected.

The `check` target now depends on `check-examples` and `compile-examples`, the latter being just a rename of the previous `examples` target.

Also, when publishing the examples using `make gh-pages` two versions of each example is published: a compiled version, and a version that uses the ol.js and ngeo.js standalone builds. The README file has been updated to explain this.

The PR also fixes a bug in the library, where a non-exported `ol` method (`ol.interaction.Interaction#getMap`) was used.

This sort of things is not a problem when everything is compiled together, but breaks when ngeo.js is used in an application. The good news is that they're now caught by the `check-examples` target.

For example, for this particular case:

```shell
$ make check-examples
mkdir -p dist/
node buildtools/build.js buildtools/ngeo.json dist/ngeo.js
info ol Parsing dependencies
info ol Compiling 11 sources
cp dist/ngeo.js .build/examples/ngeo.js
./node_modules/phantomjs/bin/phantomjs buildtools/check-example.js .build/examples/simple.html
touch .build/examples/simple.check.timestamp
./node_modules/phantomjs/bin/phantomjs buildtools/check-example.js .build/examples/layervisibility.html
touch .build/examples/layervisibility.check.timestamp
./node_modules/phantomjs/bin/phantomjs buildtools/check-example.js .build/examples/layeropacity.html
touch .build/examples/layeropacity.check.timestamp
./node_modules/phantomjs/bin/phantomjs buildtools/check-example.js .build/examples/interactiontoggle.html
console: TypeError: 'undefined' is not a function (evaluating 'a.getMap()')
at file:///home/elemoine/src/ngeo/.build/examples/ngeo.js:1
touch .build/examples/interactiontoggle.check.timestamp
```