taron133
2020-10-26 aa8d874c8a3287d41d26566ae32b6ed8d4557ff9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* global describe, it, before */
 
import chai from 'chai';
import CentrifugeJSON from '../dist/centrifuge.js';
import CentrifugeProtobuf from '../dist/centrifuge.protobuf.js';
 
chai.expect();
 
const expect = chai.expect;
 
let centrifugeJSON;
let centrifugeProtobuf;
 
describe('Given an instance of my Centrifuge', () => {
  before(() => {
    centrifugeJSON = new CentrifugeJSON('ws://localhost:8000/connection/websocket');
  });
  describe('when I need the url', () => {
    it('should return the url', () => {
      expect(centrifugeJSON._url).to.be.equal('ws://localhost:8000/connection/websocket');
    });
  });
});
 
describe('Given an instance of my Centrifuge', () => {
  before(() => {
    centrifugeJSON = new CentrifugeJSON('ws://localhost:8000/connection/websocket');
  });
  describe('when I try to send message in disconnected state', () => {
    it('send rejects a promise', () => {
      return centrifugeJSON.send({})
        .then(function () { throw new Error('was not supposed to succeed'); })
        .catch(function (m) { expect(m.code).to.equal(0); });
    });
  });
});
 
describe('Given an instance of my Centrifuge with Protobuf', () => {
  before(() => {
    centrifugeProtobuf = new CentrifugeProtobuf('ws://localhost:8000/connection/websocket');
  });
  describe('when I need the url', () => {
    it('should return the url', () => {
      expect(centrifugeProtobuf._url).to.be.equal('ws://localhost:8000/connection/websocket');
    });
  });
});