How to use the pify.mockReturnValue function in pify

To help you get started, we’ve selected a few pify 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 algolia / talksearch-scraper / src / __tests__ / fileutils.js View on Github external
it('is a promise wrapper around glob', async () => {
      module._glob = null;
      const mockGlob = jest.fn().mockReturnValue('foo');
      pify.mockReturnValue(mockGlob);

      const actual = await module.glob('pattern');

      expect(actual).toEqual('foo');
      expect(pify).toHaveBeenCalledWith(glob);
      expect(mockGlob).toHaveBeenCalledWith('pattern');
    });
  });
github algolia / talksearch-scraper / src / __tests__ / fileutils.js View on Github external
it('is a promise wrapper around fs.readFile', async () => {
      module._readFile = null;
      const mockReadFile = jest.fn().mockReturnValue('foo');
      pify.mockReturnValue(mockReadFile);

      const actual = await module.read('filepath');

      expect(actual).toEqual('foo');
      expect(pify).toHaveBeenCalledWith(fs.readFile);
      expect(mockReadFile).toHaveBeenCalledWith('filepath');
    });
  });

pify

Promisify a callback-style function

MIT
Latest version published 2 years ago

Package Health Score

73 / 100
Full package analysis

Popular pify functions