How to use the random-item.mockReturnValueOnce function in random-item

To help you get started, we’ve selected a few random-item 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 Yoctol / bottender-compose / src / __tests__ / random.spec.js View on Github external
xit('should pass extra args to underlying action', () => {
  const Haha = jest.fn();
  const Wow = jest.fn();

  const actions = [Haha, Wow];

  randomItem.mockReturnValueOnce(Haha);
  const action = random(actions);

  const context = {
    sendText: jest.fn(),
  };

  const extraArg = {};

  action(context, extraArg);

  expect(randomItem).toBeCalledWith(actions);
  expect(Haha).toBeCalledWith(context, extraArg);
});
github Yoctol / bottender-compose / src / __tests__ / random.spec.js View on Github external
it('should create action that will call sendText', async () => {
  const Haha = sendText('Haha');
  const Wow = sendText('Wow');
  const Cool = sendText('Cool');
  const actions = [Haha, Wow, Cool];

  randomItem.mockReturnValueOnce(Cool);
  const Random = random([Haha, Wow, Cool]);

  const context = {
    sendText: jest.fn(),
  };

  const Action = await Random(context);

  expect(randomItem).toBeCalledWith(actions);
  expect(Action).toEqual(Cool);
});

random-item

Get a random item from an array

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis

Popular random-item functions