Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

loggerTest.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const should = require("should");
  2. const helper = require("node-red-node-test-helper")
  3. const loggerNode = require("../loggerNode.js");
  4. //helper.init(require.resolve('node-red'));
  5. helper.init(require.resolve('node-red'), {
  6. functionGlobalContext: { os:require('os') }
  7. });
  8. console.log("helper "+Object.keys(helper));
  9. describe('Logger Node', function () {
  10. afterEach(function () {
  11. helper.unload();
  12. });
  13. var logEvents = helper.log().args.filter(function(evt) {
  14. console.log("loags "+evt[0].type)
  15. return evt[0].type == "batch";
  16. });
  17. it('should be loaded', function (done) {
  18. const flow = [{ id: "n1", type: "Logger", name: "test name" ,count: 19}];
  19. helper.load(loggerNode, flow, function () {
  20. // const n1 = helper.getNode("n1");
  21. // n1.should.have.property('name', 'test name');
  22. // n1.should.have.property('count', 19);
  23. // n1.should.have.property('sendOutputLog', false);
  24. done();
  25. });
  26. });
  27. it('should log payload ', function (done) {
  28. const flow = [
  29. { id: "n1", type: "helper" },
  30. { id: "n2", type: "helper" },
  31. { id: "n3", type: "Logger", name: "test name",wires:[["n1"]] }
  32. ];
  33. /* helper.load(loggerNode, flow, function () {
  34. const n1 = helper.getNode("n1");
  35. const n2 = helper.getNode("n2");
  36. const n3 = helper.getNode("n3");
  37. n3.on("input", function (msg) {
  38. msg.should.have.property('payload', 'testmsg');
  39. done();
  40. });
  41. n2.on("input", function (msg) {
  42. msg.should.have.property('payload', 'testmsg');
  43. done();
  44. });
  45. n1.receive({ payload: "testmsg" });
  46. });
  47. */
  48. done();
  49. });
  50. });