options.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. var test = require('tap').test;
  2. var fs = require('fs');
  3. var path = require('path');
  4. var through = require('through');
  5. var convert = require('convert-source-map');
  6. var sinon = require('sinon')
  7. var proxyquire = require('proxyquire');
  8. var spy = sinon.spy();
  9. var transform = proxyquire('..', {
  10. coffeescript: {
  11. compile: spy,
  12. }
  13. });
  14. test('unknown options are passed along', function (t) {
  15. t.plan(4);
  16. var data = '';
  17. var options = { sourceMap: false, myBool: true, myObj: { foo: 123 }, myArr: [], myString: 'bar' };
  18. var file = path.join(__dirname, '../example/foo.coffee');
  19. fs.createReadStream(file).pipe(transform(file, options)).pipe(through(write, end));
  20. function write (buf) { data += buf }
  21. function end () {
  22. var calledWith = spy.lastCall.args[1];
  23. t.equal(options.myBool, calledWith.myBool, "should pass type boolean option");
  24. t.equal(options.myObj, calledWith.myObj, "should pass type object option");
  25. t.equal(options.myArr, calledWith.myArr, "should pass type array option");
  26. t.equal(options.myString, calledWith.myString, "should pass type string option");
  27. }
  28. });