Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserModel.exists method not exist #69

Closed
aj-anuragjain opened this issue Feb 4, 2021 · 2 comments
Closed

UserModel.exists method not exist #69

aj-anuragjain opened this issue Feb 4, 2021 · 2 comments

Comments

@aj-anuragjain
Copy link

Hi Team, I did not see the UserModel.exists a method to be mocked?
Can you confirm?

@alonronin
Copy link
Owner

nope. I'll add it :)

@alonronin
Copy link
Owner

alonronin commented Mar 18, 2021

Model.exists() create the findOne ops. so to mock it you should:

it('returns false for exists method', async () => {
  mockingoose(User).toReturn(null, 'findOne');

  const result = await User.exists({ name: 'test' });

  expect(result).toBeFalsy();
});

it('returns true for exists method', async () => {
  mockingoose(User).toReturn({}, 'findOne');

  const result = await User.exists({ name: 'test' });

  expect(result).toBeTruthy();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants