a zip code crypto-currency system good for red ONLY

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import request from 'supertest';
  2. import assert from 'assert';
  3. import {parse} from 'url';
  4. import listen from './helpers/listen';
  5. import {Client as WebSocket} from 'faye-websocket';
  6. describe('tiny-lr', () => {
  7. before(listen());
  8. it('accepts ws clients', function (done) {
  9. const url = parse(this.request.url);
  10. const server = this.app;
  11. const ws = this.ws = new WebSocket('ws://' + url.host + '/livereload');
  12. ws.onopen = event => {
  13. const hello = {
  14. command: 'hello',
  15. protocols: ['http://livereload.com/protocols/official-7']
  16. };
  17. ws.send(JSON.stringify(hello));
  18. };
  19. ws.onmessage = event => {
  20. assert.deepEqual(event.data, JSON.stringify({
  21. command: 'hello',
  22. protocols: ['http://livereload.com/protocols/official-7'],
  23. serverName: 'tiny-lr'
  24. }));
  25. assert.ok(Object.keys(server.clients).length);
  26. done();
  27. };
  28. });
  29. it('properly cleans up established connection on exit', function (done) {
  30. const ws = this.ws;
  31. ws.onclose = done.bind(null, null);
  32. request(this.server)
  33. .get('/kill')
  34. .expect(200, () => {});
  35. });
  36. });