Usage
npm install --save-dev dropbox-mock
Global test setup:
globalDropbox = new ;globalDropbox;
When creating the Dropbox Client in test, you need to use the same app key that you allowed in the global test setup above.
key: 'FAKE-KEY-FOR-TEST';
After exercising code that should have created records, you can inspect the fake Dropbox datastore:
globalDropbox'MyTable'; // => yields the stored object
Currently supported APIs
new Dropbox.Client
Client.authenticate()
Client.isAuthenticated()
Client.getDatastoreManager()
DatatstoreManager.openDefaultDatastore(callback)
Datastore.getTable(name)
Datastore.recordsChanged.addListener(callback)
(must be manually triggered by your test)Table.query()
(no params)Table.insert(record)
Record.get(fieldName)
Record.deleteRecord()
Record.getId()
Record.update()
Pull requests are welcome.
Examples
Table.query()
globalDropbox = new ;globalDropbox;globalDropbox'MyTable' = name: "Record 1" value: 1 ;// call subject method that queries MyTable
Table.insert(record)
globalDropbox = new ;globalDropbox;// call subject method that should insert recordsto;
Datastore.recordsChanged.addListener(callback)
globalDropbox = new ;globalDropbox;// call subject method that should register a listenerglobalDropbox;// verify subject performed an action in response to a recordsChanged event