Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/mocks/rtc-peer-connection-stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RTCPeerConnectionStub {
): Promise<void> {
return new Promise(() => {});
}
setConfiguration(configuration?: RTCConfiguration): void {}
onconnectionstatechange: () => void = () => {};
oniceconnectionstatechange: () => void = () => {};
onicecandidate: (event: RTCPeerConnectionIceEvent) => void = () => {};
Expand Down
21 changes: 21 additions & 0 deletions src/peer-connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,27 @@ describe('PeerConnection', () => {
});
});

describe('setConfiguration', () => {
let mockPc: MockedObjectDeep<RTCPeerConnectionStub>;
let pc: PeerConnection;

beforeEach(() => {
jest.clearAllMocks();
mockPc = mocked(new RTCPeerConnectionStub(), true);
mockCreateRTCPeerConnection.mockReturnValueOnce(mockPc as unknown as RTCPeerConnection);
pc = new PeerConnection();
});

it('should call setConfiguration on the underlying peer connection', () => {
expect.hasAssertions();
const configuration: RTCConfiguration = {
iceServers: [{ urls: 'stun:stun.example.com' }],
};
pc.setConfiguration(configuration);
expect(mockPc.setConfiguration).toHaveBeenCalledWith(configuration);
});
});

describe('setRemoteDescription', () => {
let mockPc: MockedObjectDeep<RTCPeerConnectionStub>;
let setRemoteDescriptionSpy: jest.SpyInstance;
Expand Down
9 changes: 9 additions & 0 deletions src/peer-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ class PeerConnection extends EventEmitter<PeerConnectionEventHandlers> {
return this.iceCandidates;
}

/**
* Sets the current configuration of the underlying RTCPeerConnection.
*
* @param configuration - An RTCConfiguration object which provides the options to be set.
*/
setConfiguration(configuration: RTCConfiguration): void {
this.pc.setConfiguration(configuration);
}
Comment thread
k-wasniowski marked this conversation as resolved.

/**
* Adds a new media track to the set of tracks which will be transmitted to the other peer.
*
Expand Down
Loading