test.js 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const log = console.log;
  2. console.log = function() {};
  3. var assert = require('assert');
  4. const io = require('socket.io-client');
  5. const backendModuleManager = require("../backend/index.js");
  6. describe('IO module', function() {
  7. let socket = null;
  8. describe("Connect", function() {
  9. it("should connect", function(done) {
  10. this.timeout(10000);
  11. socket = io("http://localhost:8080");
  12. socket.on("connect", () => {
  13. done();
  14. });
  15. socket.on("connect_error", () => {
  16. done(new Error("Connect error"));
  17. });
  18. });
  19. });
  20. describe('Handlers', function() {
  21. describe('getAccounts', function() {
  22. const expectedAccounts = {
  23. accounts: []
  24. };
  25. it('should return a list of accounts', function(done) {
  26. socket.emit("getAccounts", res => {
  27. assert.equal(res.accounts, expectedAccounts);
  28. done();
  29. });
  30. });
  31. });
  32. });
  33. });