forked from amazon-connect/amazon-connect-streams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreams.spec.js
62 lines (51 loc) · 2.21 KB
/
streams.spec.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require("../unit/test-setup.js");
describe('Streams', function () {
jsdom({ url: "http://localhost" });
describe('WindowStream', function () {
it('Validate send and onMessage methods are implemented', function () {
var windowStream = new connect.WindowStream(window, "amazon.com");
assert.isFunction(windowStream.send);
assert.isFunction(windowStream.onMessage);
assert.exists(windowStream.window);
assert.exists(windowStream.domain);
});
});
describe('WindowIOStream', function () {
it('Validate send and onMessage methods are implemented with input and output - communication between IFrame/popup windows', function () {
var WindowIOStream = new connect.WindowIOStream(window, window, "amazon.com");
assert.isFunction(WindowIOStream.send);
assert.isFunction(WindowIOStream.onMessage);
assert.exists(WindowIOStream.input);
assert.exists(WindowIOStream.output);
assert.exists(WindowIOStream.domain);
});
});
describe('PortStream', function () {
it('Validate workers stream is initialized properly with the connected port', function () {
var PortStream = new connect.PortStream(1000);
assert.isFunction(PortStream.send);
assert.isFunction(PortStream.onMessage);
assert.exists(PortStream.port);
});
});
describe('Conduit', function () {
before(function () {
this.stream = {
send: sinon.spy(),
onMessage: sinon.spy()
}
});
it('validate send downstream and upstream APIs', function () {
var conduit = new connect.Conduit("ConnectSharedWorkerConduit",
this.stream, this.stream);
conduit.sendDownstream("Event", {});
expect(conduit.upstream.send.withArgs("Event", {}).calledOnce);
conduit.sendUpstream("Event", {});
expect(conduit.downstream.send.withArgs("Event", {}).calledOnce);
});
});
describe('TODO', function () {
it('Test cases for Stream Multiplexer');
it('Test cases for Iframe condult');
});
});