diff --git a/src/js/common/browserInfoHelper.js b/src/js/common/browserInfoHelper.js index 4528a9f..b513160 100644 --- a/src/js/common/browserInfoHelper.js +++ b/src/js/common/browserInfoHelper.js @@ -38,7 +38,7 @@ export const getDeviceLocalIPAsString = () => { deviceIpString = ip.join(","); resolve(deviceIpString); } - if (event.candidate.candidate) { + else if (event.candidate.candidate) { const candidateValues = event.candidate.candidate.split(" "); if (candidateValues.length > ICE_CANDIDATE_IP_INDEX) { ip.push(candidateValues[ICE_CANDIDATE_IP_INDEX]); diff --git a/tests/unit/common/browserInfoHelper.test.js b/tests/unit/common/browserInfoHelper.test.js index e7ad902..0187f8a 100644 --- a/tests/unit/common/browserInfoHelper.test.js +++ b/tests/unit/common/browserInfoHelper.test.js @@ -157,13 +157,13 @@ describe("BrowserInfoHelper", () => { throw new Error("Expected an error to be thrown, but it was not"); }); - it("RTCPeerConnection throws unexpected error", async () => { + it("RTCPeerConnection throws CREATE_CONNECTION_ERROR", async() => { webRtcConnectionStub.mockReturnValue(MockErrorRTCPeerConnection); try { await getDeviceLocalIPAsString(); } catch (error) { expect(error.toString()).toEqual( - "Error: MockErrorRTCPeerConnection error thrown" + "CREATE_CONNECTION_ERROR" ); return; } diff --git a/tests/unit/mock/MockRTCPeerConnection.js b/tests/unit/mock/MockRTCPeerConnection.js index 30e168a..843f338 100644 --- a/tests/unit/mock/MockRTCPeerConnection.js +++ b/tests/unit/mock/MockRTCPeerConnection.js @@ -37,7 +37,7 @@ export class MockRTCPeerConnection { } export class MockErrorRTCPeerConnection extends MockRTCPeerConnection { - createDataChannel() { - throw new Error("MockErrorRTCPeerConnection error thrown"); + createOffer() { + return Promise.reject(); } }