From 2e18777e571497dd5d4cc108d7d9215b3fa5458c Mon Sep 17 00:00:00 2001 From: jdlubrano Date: Tue, 8 Sep 2015 22:30:32 -0400 Subject: [PATCH] Add Meteor export file so that the nv object is available globally in Meteor apps. --- .travis.yml | 7 +++++++ README.md | 5 +++++ meteor/export.js | 4 ++++ package.js | 9 ++++++++- test/tinytest/nv-is-defined-test.js | 6 ++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 meteor/export.js create mode 100644 test/tinytest/nv-is-defined-test.js diff --git a/.travis.yml b/.travis.yml index de764f665..928e7e272 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,13 @@ before_install: - "npm install -g grunt-cli" - "export DISPLAY=:99.0" - "sh -e /etc/init.d/xvfb start" +# Meteor Tinytest support + - "curl https://install.meteor.com | /bin/sh" + - export PATH="$HOME/.meteor:$PATH" + - "npm install -g spacejam" install: - "npm install" - "bower install" + +script: "spacejam test-packages ./" + diff --git a/README.md b/README.md index 40d76bd82..4e5c78b97 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,11 @@ only include the source files you changed! * Also visually inspect the HTML pages in the **examples/ and test/ folders**. Make sure there are no glaring errors. * Novus now uses Travis CI for continuous integration. Visit [our travis build page](https://travis-ci.org/novus/nvd3/) to see the latest status. +#### Meteor Tinytests +* Any Meteor-specific features can be tested from the command line using `tinytest` and [Spacejam](https://www.npmjs.com/package/spacejam) +* `spacejam` can be installed by running `npm install -g spacejam`. +* Tinytests can then be executed by running `spacejam test-packages nvd3:nvd3`. + --- ## Building latest diff --git a/meteor/export.js b/meteor/export.js new file mode 100644 index 000000000..dc7387f62 --- /dev/null +++ b/meteor/export.js @@ -0,0 +1,4 @@ +/*global nv:true*/ // Meteor creates a file-scope global for exporting. This comment prevents a potential JSHint warning. +nv = window.nv; +delete window.nv; + diff --git a/package.js b/package.js index 9970c1527..bd049a144 100644 --- a/package.js +++ b/package.js @@ -13,5 +13,12 @@ Package.on_use(function (api) { api.use('d3js:d3@3.5.5', 'client'); api.add_files('build/nv.d3.js', 'client'); api.add_files('build/nv.d3.css', 'client'); + api.add_files('meteor/export.js', 'client'); api.export("nv"); -}); \ No newline at end of file +}); +Package.onTest(function(api) { + api.use(['tinytest', 'test-helpers']); + api.use('d3js:d3', 'client'); + api.addFiles(['build/nv.d3.js', 'meteor/export.js'], "client"); + api.addFiles('test/tinytest/nv-is-defined-test.js', "client"); +}); diff --git a/test/tinytest/nv-is-defined-test.js b/test/tinytest/nv-is-defined-test.js new file mode 100644 index 000000000..48116913b --- /dev/null +++ b/test/tinytest/nv-is-defined-test.js @@ -0,0 +1,6 @@ +// nv-is-defined-test.js + +Tinytest.add('nv object is defined', function(test) { + test.isNotUndefined(nv, 'nv is undefined at global scope for Meteor'); +}); +