test-helper.js 661 B

1234567891011121314151617181920212223
  1. const runInlineTest = require('jscodeshift/dist/testUtils').runInlineTest;
  2. /**
  3. * Test a transform function.
  4. *
  5. * @param {Function} transform
  6. * @param {String} path - (fake) file path of source passed to transform
  7. * @param {String} input - Source code
  8. * @param {String} output - Expected transform result
  9. * @param {Object} options - Options passed to transform, optional
  10. */
  11. function testTransform(transform, path, input, output, options = {}) {
  12. const fileInfo = {
  13. path,
  14. source: input
  15. };
  16. it('transforms correctly', () => {
  17. runInlineTest(transform, options, fileInfo, output);
  18. });
  19. }
  20. module.exports.testTransform = testTransform;