A small 'live' web site which uses rest-api to represent a pseudo-termial-like interface.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

94 rindas
2.4KB

  1. const expect = require('chai').expect
  2. var debug = require('debug');
  3. describe('Tests for app/logging module', function(){
  4. beforeEach(function(){
  5. if (!this.debug){
  6. var debugcb = this.sandbox.spy();
  7. debugcb.namespace = "";
  8. debugcb.enabled = true;
  9. debugcb.destroy = function(){};
  10. //console.log(require.cache[require.resolve('debug')]);
  11. this.debugcb = debugcb;
  12. this.debug = this.sandbox.stub(require.cache[require.resolve('debug')], 'exports').callsFake(function(ns){
  13. debugcb.namespace = ns;
  14. return debugcb;
  15. });
  16. }
  17. });
  18. it('Create Log instance', function(){
  19. let log = (require('../app/logging')).createLog("test");
  20. expect(this.debug.called).to.eql(true);
  21. });
  22. it('Log instance persists.', function(){
  23. expect((require('../app/logging')).length).to.eql(1);
  24. });
  25. it('No duplicates when same namespace used.', function(){
  26. let lsys = require('../app/logging');
  27. let log = lsys.createLog("test");
  28. expect(lsys.length).to.eql(1);
  29. });
  30. it('Clear all current logs.', function(){
  31. let lsys = require('../app/logging');
  32. lsys.clear();
  33. expect(lsys.length).to.eql(0);
  34. });
  35. describe('Testing core log methods', function(){
  36. after(function(){
  37. (require('../app/logging')).clear();
  38. });
  39. it('.info()', function(){
  40. let log = (require('../app/logging')).createLog("test");
  41. let msg = "Test Burger";
  42. log.info(msg);
  43. expect(this.debugcb.calledWith("[ INFO ]: " + msg)).to.eql(true);
  44. });
  45. it('.debug()', function(){
  46. let log = (require('../app/logging')).createLog("test");
  47. let msg = "Test Burger";
  48. log.debug(msg);
  49. expect(this.debugcb.calledWith("[ DEBUG ]: " + msg)).to.eql(true);
  50. });
  51. it('.warning()', function(){
  52. let log = (require('../app/logging')).createLog("test");
  53. let msg = "Test Burger";
  54. log.warning(msg);
  55. expect(this.debugcb.calledWith("[ WARNING ]: " + msg)).to.eql(true);
  56. });
  57. it('.error()', function(){
  58. let log = (require('../app/logging')).createLog("test");
  59. let msg = "Test Burger";
  60. log.error(msg);
  61. expect(this.debugcb.calledWith("[ ERROR ]: " + msg)).to.eql(true);
  62. });
  63. it('.critical()', function(){
  64. let log = (require('../app/logging')).createLog("test");
  65. let msg = "Test Burger";
  66. log.critical(msg);
  67. expect(this.debugcb.calledWith("[ CRITICAL ]: " + msg)).to.eql(true);
  68. });
  69. });
  70. });