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

test-mongoose-utils

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-mongoose-utils

Test utils using mongoose.

  • 0.4.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Test Mongoose Utils

Installation

$ npm install test-mongoose-utils

Example Usage

const TestMongooseUtils = require('test-mongoose-utils');
const tmu = new TestMongooseUtils();

const Todo = require('./Todo');

describe('module', () => {
  before(done => {
    tmu.registerModels([Todo]); // Enables some functionality.
    // connect to mongoose...
  });

  after(done => {
    tmu.restore(); // Restores spies.
    // disconnect to mongoose...
  });

  afterEach(() => {
    tmu.reset(); // Resets spies' records.
  });

  test('Todo uuid is unique', done => {
    const data = { uuid: 'bananaMan' };
    const createTodo = mainCb =>
      tmu.assertChanges({ // Will assert @expectedChanges after @act.
        act: cb =>
          Todo.create(data, cb),
        expectedChanges: {
          db: {
            // Tells tmu to assert that Todo.count({}) incr's by 1 after @act.
            counts: [[Todo, {}, 1]]
          }
        }
      }, mainCb);
    const createTodoDupe = mainCb =>
      tmu.assertChanges({ // Will assert @expectedChanges after @act.
        act: cb =>
          Todo.create(data, cb),
        expectedChanges: {
          db: {
            // Tells tmu to assert that Model.<mutate>
            // or Model.prototype.<mutate> methods were not called.
            wasMutated: [[Todo, false]]
          }
        }
      }, mainCb);

    async.series([
      createTodo,
      createTodoDupe
    ], done);
  });
});

Keywords

FAQs

Package last updated on 25 Dec 2017

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