1 | "use strict";
|
2 |
|
3 | module.exports.mockLoggingService = function () {
|
4 | return jasmine.createSpyObj('loggingService', ['error', 'debug', 'info', 'warn']);
|
5 | };
|
6 |
|
7 | module.exports.mockCyclonNode = function () {
|
8 | return jasmine.createSpyObj('cyclonNode', ['getId', 'start', 'executeShuffle', 'createNewPointer', 'handleShuffleRequest', 'handleShuffleResponse', 'emit']);
|
9 | };
|
10 |
|
11 | module.exports.mockRtc = function () {
|
12 | return jasmine.createSpyObj('rtc', ['connect', 'onChannel', 'openChannel', 'on', 'createNewPointer', 'getLocalId']);
|
13 | };
|
14 |
|
15 | module.exports.mockChannel = function() {
|
16 | return jasmine.createSpyObj('channel', ['getRemotePeer', 'createOffer', 'createAnswer', 'sendAnswer', 'waitForChannelEstablishment', 'waitForIceCandidates', 'sendOffer', 'handleAnswer', 'waitForChannelToOpen', 'send', 'receive', 'close', 'cancel']);
|
17 | };
|
18 |
|
19 | module.exports.mockAsyncExecService = function () {
|
20 | return jasmine.createSpyObj('asyncExecService', ['setTimeout', 'setInterval', 'clearTimeout', 'clearInterval']);
|
21 | };
|
22 |
|
23 | module.exports.mockSignallingSocket = function () {
|
24 | return jasmine.createSpyObj('signallingSocket', ['getCurrentServerSpecs', 'initialize', 'on']);
|
25 | };
|
26 |
|
27 | module.exports.mockHttpRequestService = function () {
|
28 | return jasmine.createSpyObj('httpRequestService', ['get', 'post']);
|
29 | };
|
30 |
|
31 | module.exports.mockShuffleStateFactory = function () {
|
32 | return jasmine.createSpyObj('shuffleStateFactory', ['createOutgoingShuffleState', 'createIncomingShuffleState']);
|
33 | };
|
34 |
|
35 | module.exports.mockOutgoingShuffleState = function (name) {
|
36 | return jasmine.createSpyObj(name || 'outgoingShuffleState', ['sendShuffleRequest', 'processShuffleResponse', 'sendResponseAcknowledgement', 'storeChannel', 'close', 'cancel']);
|
37 | };
|
38 |
|
39 | module.exports.mockIncomingShuffleState = function () {
|
40 | return jasmine.createSpyObj('incomingShuffleState', ['processShuffleRequest', 'waitForResponseAcknowledgement', 'close', 'cancel']);
|
41 | };
|
42 |
|
43 | module.exports.mockNeighbourSet = function () {
|
44 | return jasmine.createSpyObj('neighbourSet', ['contains', 'insert', 'remove', 'get', 'size', 'selectShuffleSet', 'findOldestId', 'randomSelection', 'incrementAges', 'resetAge', 'mergeNodePointerIfNewer']);
|
45 | };
|
46 |
|
47 | module.exports.mockComms = function () {
|
48 | return jasmine.createSpyObj('comms', ['sendShuffleRequest', 'sendShuffleResponse', 'getPointerData']);
|
49 | };
|
50 |
|
51 | module.exports.mockStorage = function() {
|
52 | return jasmine.createSpyObj('storage', ['getItem', 'setItem']);
|
53 | };
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | module.exports.createSuccessCallback = function () {
|
59 | return jasmine.createSpy('successCallback');
|
60 | };
|
61 |
|
62 | module.exports.createFailureCallback = function () {
|
63 | return jasmine.createSpy('failureCallback').and.callFake(function (error) {
|
64 |
|
65 | });
|
66 | };
|
67 |
|
68 | module.exports.mockPromise = function() {
|
69 | var mockPromise = jasmine.createSpyObj('mockPromise', ['isPending', 'close', 'cancel', 'then', 'catch', 'cancellable']);
|
70 | mockPromise.then.and.returnValue(mockPromise);
|
71 | mockPromise.cancellable.and.returnValue(mockPromise);
|
72 | mockPromise.catch.and.returnValue(mockPromise);
|
73 | return mockPromise;
|
74 | };
|