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

chai-sync-layer-suite

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-sync-layer-suite

Chai suite for sync-layer library

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

chai-sync-layer-suite

Set of Chai matchers and helpers that simplifies process of testing sync layer (TODO wtf is sync layer).

Installation

Install via npm:

npm install --save-dev chai-sync-layer-suite

Then require it in your test helper:

// Matchers:
var syncMatchers = require('chai-sync-layer-suite/src/sync_matchers');
chai.use(syncMatchers);

// Describe helper
var describeSync = require('chai-sync-layer-suite/src/describe_sync');
window.describeSync = describeSync; // Export to global scope (window for Karma)

Usage

Real life usage example:

invitations_sync.js:

var requests = require('stores/requests');

var invitationsSync = {
  get: function(token) {
    return requests.get('/invitations/' + token);
  },

  create: function(projectId, payload) {
    return requests.signedPost(
      '/projects/' + projectId + '/invitations', payload
    );
  },

  delete: function(token) {
    return requests.signedDelete('/invitations/' + token);
  },

  accept: function(token) {
    return requests.signedPut('/invitations/' + token);
  }
};

module.exports = invitationsSync;

invitations_sync_test.js:

var invitationsSync = rewire('../invitations_sync');

describeSync('invitationsSync', invitationsSync, function() {
  it('get', function() {
    expect(invitationsSync.get.with('zaq1xsw2')).to.perform.request(
      'get', '/invitations/zaq1xsw2'
    );
  });

  it('create', function() {
    expect(invitationsSync.create.with(42, { a: 'A' })).to.perform.request(
      'signedPost', '/projects/42/invitations', { a: 'A' }
    );
  });

  it('delete', function() {
    expect(invitationsSync.delete.with('zaq1xsw2')).to.perform.request(
      'signedDelete', '/invitations/zaq1xsw2'
    );
  });

  it('accept', function() {
    expect(invitationsSync.accept.with('zaq1xsw2')).to.perform.request(
      'signedPut', '/invitations/zaq1xsw2'
    );
  });
});

Tests

npm test

For watch mode:

npm run-script autotest

Roadmap

  • More docs
  • Simpler describeSync API
  • Matchers and helpers for rest parts of sync layer

--

License (MIT)

FAQs

Package last updated on 09 Mar 2016

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