Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dropbox-mock

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dropbox-mock

Test double for Dropbox API

  • 0.0.7
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status Stability: 2 - unstable

Usage

npm install --save-dev dropbox-mock

Global test setup:

global.Dropbox = new (require('dropbox-mock'))();
global.Dropbox.allowAppKey('FAKE-KEY-FOR-TEST');

When creating the Dropbox Client in test, you need to use the same app key that you allowed in the global test setup above.

new Dropbox.Client({key: 'FAKE-KEY-FOR-TEST'});

After exercising code that should have created records, you can inspect the fake Dropbox datastore:

global.Dropbox['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()

global.Dropbox = new (require('dropbox-mock'))();
global.Dropbox.allowAppKey('FAKE-KEY-FOR-TEST');
global.Dropbox['MyTable'] = [ { name: "Record 1", value: 1 } ];
// call subject method that queries MyTable

Table.insert(record)

global.Dropbox = new (require('dropbox-mock'))();
global.Dropbox.allowAppKey('FAKE-KEY-FOR-TEST');
// call subject method that should insert records
expect(global.Dropbox['MyTable']).to.equal(expectedRecords);

Datastore.recordsChanged.addListener(callback)

global.Dropbox = new (require('dropbox-mock'))();
global.Dropbox.allowAppKey('FAKE-KEY-FOR-TEST');
// call subject method that should register a listener
global.Dropbox.triggerRecordsChanged();
// verify subject performed an action in response to a recordsChanged event

Keywords

FAQs

Package last updated on 16 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc