How to use mockingoose - 10 common examples

To help you get started, we’ve selected a few mockingoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenNeuroOrg / openneuro / packages / openneuro-server / datalad / __tests__ / snapshots.spec.js View on Github external
beforeEach(() => {
      mockingoose.resetAll()
      // Setup a default sequence value to return for each test
      mockingoose.Counter.toReturn(
        { _id: 'dataset', sequence_value: 1 },
        'findOneAndUpdate',
      )
    })
    it('posts to the DataLad /datasets/{dsId}/snapshots/{snapshot} endpoint', async done => {
github OpenNeuroOrg / openneuro / packages / openneuro-server / datalad / __tests__ / snapshots.spec.js View on Github external
beforeEach(() => {
      mockingoose.resetAll()
      // Setup a default sequence value to return for each test
      mockingoose.Counter.toReturn(
        { _id: 'dataset', sequence_value: 1 },
        'findOneAndUpdate',
      )
    })
    it('posts to the DataLad /datasets/{dsId}/snapshots/{snapshot} endpoint', async done => {
github OpenNeuroOrg / openneuro / packages / openneuro-server / datalad / __tests__ / pagination.spec.js View on Github external
beforeEach(() => {
      mockingoose.resetAll()
      mockingoose.Dataset.toReturn(
        [
          {
            datasets: [
              {
                _id: ObjectID('5bef51a1ed211400c08e5524'),
                id: 'ds001001',
                created: new Date('2018-11-16T23:24:17.203Z'),
                modified: new Date('2018-11-16T23:24:25.050Z'),
                uploader: 'f8d5a57c-879a-40e6-b151-e34c4a28ff70',
                revision: '262a8e610e32b5766cbf669acc71911c1ece7126',
              },
            ],
            count: 1,
          },
        ],
github OpenNeuroOrg / openneuro / packages / openneuro-server / datalad / __tests__ / pagination.spec.js View on Github external
beforeEach(() => {
      mockingoose.resetAll()
      mockingoose.Dataset.toReturn(
        [
          {
            datasets: [
              {
                _id: ObjectID('5bef51a1ed211400c08e5524'),
                id: 'ds001001',
                created: new Date('2018-11-16T23:24:17.203Z'),
                modified: new Date('2018-11-16T23:24:25.050Z'),
                uploader: 'f8d5a57c-879a-40e6-b151-e34c4a28ff70',
                revision: '262a8e610e32b5766cbf669acc71911c1ece7126',
              },
            ],
            count: 1,
          },
        ],
        'aggregate',
github jimmyleray / Emendare / old-server / src / models / text / Text.spec.ts View on Github external
test('should return user not connected', async () => {
    mockingoose.User.toReturn(null, 'findOne')
    expect(await Text.followText('5c64389cae3ae3695c711e44', '')).toMatchObject(
      {
        error: {
          code: 401,
          message: "Cet utilisateur n'est pas connecté"
        }
      }
    )
    mockingoose.User.toReturn({ ...userMock, activated: false }, 'findOne')
    expect(
      await Text.followText('5c64389cae3ae3695c711e44', 'az200J')
    ).toMatchObject({
      error: {
        code: 401,
        message: "Cet utilisateur n'est pas connecté"
      }
github jimmyleray / Emendare / old-server / src / models / amend / Amend.spec.ts View on Github external
test('User is not connected', async () => {
    mockingoose.User.toReturn(null, 'findOne')
    expect(
      await Amend.downVoteAmend('5c64389cae3ae3695c711e44', 'wrongToken')
    ).toMatchObject({
      error: { code: 401, message: "Cet utilisateur n'est pas connecté" }
    })
  })
github jimmyleray / Emendare / old-server / src / models / user / User.spec.ts View on Github external
test('should return error message account already activated', async () => {
    const activatedUser = {
      ...userMock,
      activated: true
    }
    mockingoose.User.toReturn(activatedUser, 'findOne').reset('find')
    expect(
      await User.activateUser('4d55a560ea0be764c55dc01a872c8fc8205cf262994c8')
    ).toMatchObject({
      error: {
        code: 405,
        message: 'Ce compte est déjà activé'
      }
    })
  })
github rolling-scopes / rsschool-app / app / routes / user / feed.spec.ts View on Github external
xit('returns 404 if no user', async () => {
        const ctx = createTestContext();
        mockingoose.User.toReturn(null, 'findOne');

        await getFeedRoute(ctx);
        expect(ctx.status).toBe(404);
        expect(ctx.body).toMatchSnapshot();
    });
});
github jimmyleray / Emendare / old-server / src / models / text / Text.spec.ts View on Github external
test('should return text already followed', async () => {
    mockingoose.User.toReturn(
      { ...userMock, followedTexts: ['5c64389cae3ae3695c711e44'] },
      'findOne'
    )
    mockingoose.Text.toReturn(null, 'findOne')
    expect(
      await Text.followText('5c64389cae3ae3695c711e44', 'uv65v76v6779b9')
    ).toMatchObject({
      error: { code: 405, message: 'Vous participez déjà à ce texte' }
    })
  })
github rolling-scopes / rsschool-app / app / routes / user / feed.spec.ts View on Github external
xit('returns data', async () => {
        const ctx = createTestContext();
        const feedRecords = [
            {
                _id: '5b19146f65bbc725d2069082',
                actionType: FeedActions.ENROLL,
                courseId: 'course-id',
                data: {},
                dateTime: 0,
                entityType: FeedEntities.User,
                userId: 'apalchys',
            },
        ] as IFeedRecordModel[];

        mockingoose.User.toReturn({}, 'findOne');
        mockingoose.FeedRecord.toReturn(feedRecords, 'find');

        await getFeedRoute(ctx);
        expect(ctx.status).toBe(200);
        expect(ctx.body).toMatchSnapshot();
    });

mockingoose

A Jest package for mocking mongoose models

Unlicense
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis