Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用require.js和jasmine模拟Google Earth事件_Javascript_Requirejs_Jasmine_Google Earth - Fatal编程技术网

Javascript 使用require.js和jasmine模拟Google Earth事件

Javascript 使用require.js和jasmine模拟Google Earth事件,javascript,requirejs,jasmine,google-earth,Javascript,Requirejs,Jasmine,Google Earth,我有下面的模块,但是在我的jasmine测试(即,在我的测试工具内部)中,我很难将其设置为模拟。特别是,我想知道我将如何/应该如何替换async!https://www.google.com/jsapi 在测试工具的上下文中调用(或硬编码的url引用),以及我将在“google.load”和“google.earth.createInstance”的测试中监视哪些事件,以便在我的测试中正确触发回调?在下面的示例代码中,uiSelector参数将是加载地球地图的div id 提前感谢您抽出时间 d

我有下面的模块,但是在我的jasmine测试(即,在我的测试工具内部)中,我很难将其设置为模拟。特别是,我想知道我将如何/应该如何替换async!https://www.google.com/jsapi 在测试工具的上下文中调用(或硬编码的url引用),以及我将在“google.load”和“google.earth.createInstance”的测试中监视哪些事件,以便在我的测试中正确触发回调?在下面的示例代码中,uiSelector参数将是加载地球地图的div id

提前感谢您抽出时间

define('googleearthloader',
[ "async!https://www.google.com/jsapi" ],
function() {

return {
        init: function(uiSelector, callbackSuccess,callbackError) {
            google.load("earth", "1", { 'callback': function() { google.earth.createInstance(uiSelector, callbackSuccess, callbackError); } });
            }

       };

});
您可以这样做:

var spy = sinon.stub(google, 'load');
.....your init call
expect(spy).toHaveBeenCalledWith("earth1", "1");
你可以通过这个间谍存根调用测试你想要什么