()
| 17 | } |
| 18 | |
| 19 | protected tests() { |
| 20 | test("Calling a remote function with a data package should send it across to the other side untampered", () => { |
| 21 | let comm = this.getMockCommunicators(); |
| 22 | |
| 23 | comm.alpha.registerFunction(TestConstants.sampleFunction, (data) => { |
| 24 | strictEqual(data, "sample data", "Ensure remote function calls pass along data params"); |
| 25 | }); |
| 26 | |
| 27 | comm.beta.callRemoteFunction(TestConstants.sampleFunction, { param: "sample data" }); |
| 28 | }); |
| 29 | |
| 30 | test("callRemoteFunction should call the callback with the resolved data if it is specified", (assert: QUnitAssert) => { |
| 31 | let done = assert.async(); |
| 32 | let comm = this.getMockCommunicators(); |
| 33 | |
| 34 | comm.alpha.registerFunction(TestConstants.sampleFunction, () => { |
| 35 | return Promise.resolve("returned data"); |
| 36 | }); |
| 37 | |
| 38 | comm.beta.callRemoteFunction(TestConstants.sampleFunction, { param: "initial data", callback: (data) => { |
| 39 | strictEqual(data, "returned data", "Ensure remote function calls pass along data params"); |
| 40 | done(); |
| 41 | }}); |
| 42 | }); |
| 43 | |
| 44 | test("If callRemoteFunction is called before the other side's function has been registered, it should be called when it is", (assert: QUnitAssert) => { |
| 45 | let done = assert.async(); |
| 46 | let comm = this.getMockCommunicators(); |
| 47 | |
| 48 | comm.beta.callRemoteFunction(TestConstants.sampleFunction, { param: "initial data", callback: (data) => { |
| 49 | strictEqual(data, "returned data", "Ensure remote function calls pass along data params"); |
| 50 | done(); |
| 51 | }}); |
| 52 | |
| 53 | comm.alpha.registerFunction(TestConstants.sampleFunction, () => { |
| 54 | return Promise.resolve("returned data"); |
| 55 | }); |
| 56 | }); |
| 57 | |
| 58 | test("Test passing smart values across the communicator and updating them", (assert: QUnitAssert) => { |
| 59 | let done = assert.async(); |
| 60 | let comm = this.getMockCommunicators(); |
| 61 | |
| 62 | let alphaValue = new SmartValue<string>("initial alpha"); |
| 63 | let betaValue = new SmartValue<string>("initial beta"); |
| 64 | |
| 65 | let count = 0; |
| 66 | comm.alpha.subscribeAcrossCommunicator(alphaValue, TestConstants.sampleSmartValue, (data: string) => { |
| 67 | count++; |
| 68 | if (count === 1) { |
| 69 | strictEqual(data, "initial beta"); |
| 70 | } else if (count === 2) { |
| 71 | strictEqual(data, "updated value"); |
| 72 | done(); |
| 73 | } |
| 74 | }); |
| 75 | |
| 76 | comm.beta.broadcastAcrossCommunicator(betaValue, TestConstants.sampleSmartValue); |
nothing calls this directly
no test coverage detected