Commit f3c3d0d3 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Remove unnecessary test seam

parent 35f64c35
...@@ -18,7 +18,6 @@ function createTimeout(delay, message) { ...@@ -18,7 +18,6 @@ function createTimeout(delay, message) {
* @param {any[]} params - Parameters of the JSON-RPC method * @param {any[]} params - Parameters of the JSON-RPC method
* @param {number} [timeout] - Maximum time to wait in ms * @param {number} [timeout] - Maximum time to wait in ms
* @param {Window} [window_] - Test seam. * @param {Window} [window_] - Test seam.
* @param {string} [id] - Test seam.
* @return {Promise<any>} - A Promise for the response to the call * @return {Promise<any>} - A Promise for the response to the call
*/ */
export function call( export function call(
...@@ -27,9 +26,11 @@ export function call( ...@@ -27,9 +26,11 @@ export function call(
method, method,
params = [], params = [],
timeout = 2000, timeout = 2000,
window_ = window, /* istanbul ignore next */
id = generateHexString(10) window_ = window
) { ) {
const id = generateHexString(10);
// Send RPC request. // Send RPC request.
const request = { const request = {
jsonrpc: '2.0', jsonrpc: '2.0',
......
import EventEmitter from 'tiny-emitter'; import EventEmitter from 'tiny-emitter';
import { call } from '../postmessage-json-rpc'; import { call, $imports } from '../postmessage-json-rpc';
class FakeWindow { class FakeWindow {
constructor() { constructor() {
...@@ -19,20 +19,21 @@ describe('sidebar/util/postmessage-json-rpc', () => { ...@@ -19,20 +19,21 @@ describe('sidebar/util/postmessage-json-rpc', () => {
let fakeWindow; let fakeWindow;
function doCall(timeout = 1) { function doCall(timeout = 1) {
return call( return call(frame, origin, 'testMethod', [1, 2, 3], timeout, fakeWindow);
frame,
origin,
'testMethod',
[1, 2, 3],
timeout,
fakeWindow,
messageId
);
} }
beforeEach(() => { beforeEach(() => {
frame = { postMessage: sinon.stub() }; frame = { postMessage: sinon.stub() };
fakeWindow = new FakeWindow(); fakeWindow = new FakeWindow();
$imports.$mock({
'../../shared/random': {
generateHexString: sinon.stub().returns(messageId),
},
});
});
afterEach(() => {
$imports.$restore();
}); });
it('sends a message to the target frame', () => { it('sends a message to the target frame', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment