cloudcmd/lib/client/storage/dropbox/doc/development.md
2012-12-17 10:52:33 -05:00

2.7 KiB

dropbox.js Development

Read this document if you want to build dropbox.js or modify its source code. If you want to write applications using dropbox.js, check out the Getting Started.

The library is written using CoffeeScript, built using cake, minified using uglify.js, tested using mocha and chai.js, and packaged using npm.

If you don't "speak" CoffeeScript, this document might address some of your concerns.

Dev Environment Setup

Install node.js to get npm (the node package manager), then use it to install the libraries required by the test suite.

git clone https://github.com/dropbox/dropbox-js.git
cd dropbox-js
npm install

Build

Run npm pack and ignore any deprecation warnings that might come up.

npm pack

The build output is in the lib/ directory. dropbox.js is the compiled library that ships in the npm package, and dropbox.min.js is a minified version, optimized for browser apps.

Test

First, you will need to obtain a couple of Dropbox tokens that will be used by the automated tests.

cake tokens

Re-run the command above if the tests fail due to authentication errors.

Once you have Dropbox tokens, you can run the test suite in node.js or in your default browser.

cake test
cake webtest

The library is automatically re-built when running tests, so you don't need to run npm pack. Please run the tests in both node.js and a browser before submitting pull requests.

The tests store all their data in folders named along the lines of js tests.0.ac1n6lgs0e3lerk9. If tests fail, you might have to clean up these folders yourself.

Testing Chrome Extension

The test suite opens up a couple of Dropbox authorization pages, and a page that cannot close itself. dropbox.js ships with a Google Chrome extension that can fully automate the testing process on Chrome.

The extension is written in CoffeeScript, so you will have to compile it.

cake extension

After compilation, have Chrome load the unpacked extension at test/chrome_extension and click on the scary-looking toolbar icon to activate the extension. The icon's color should turn red, to indicate that it is active.

The extension performs some checks to prevent against attacks. However, for best results, you should disable the automation (by clicking on the extension icon) when you're not testing dropbox.js.