test.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. describe('diagnostics', function () {
  2. 'use strict';
  3. var assume = require('assume')
  4. , debug = require('./');
  5. beforeEach(function () {
  6. process.env.DEBUG = '';
  7. process.env.DIAGNOSTICS = '';
  8. });
  9. it('is exposed as function', function () {
  10. assume(debug).to.be.a('function');
  11. });
  12. it('stringifies objects', function (next) {
  13. process.env.DEBUG = 'test';
  14. debug.to({
  15. write: function write(line) {
  16. assume(line).to.contain('test');
  17. assume(line).to.contain('I will be readable { json: 1 }');
  18. debug.to(process.stdout);
  19. next();
  20. }
  21. });
  22. debug('test')('I will be readable', { json: 1 });
  23. });
  24. describe('.to', function () {
  25. it('globally overrides the stream', function (next) {
  26. process.env.DEBUG = 'foo';
  27. debug.to({
  28. write: function write(line) {
  29. assume(line).to.contain('foo');
  30. assume(line).to.contain('bar');
  31. debug.to(process.stdout);
  32. next();
  33. }
  34. });
  35. var log = debug('foo');
  36. log('bar');
  37. });
  38. });
  39. });