【发布时间】:2015-02-28 02:27:02
【问题描述】:
我正在使用 Chutzpah 测试我的 TypeScript,但它似乎无法识别 Bing 地图 CDN:“http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0”。我尝试将它作为参考路径包含在 chutzpah.json 文件中,但没有效果。知道我可能做错了什么吗?
来源(MapViewer.ts):
/// <reference path="../scripts/typings/bingmaps/microsoft.maps.d.ts" />
module Viewers {
export class MapViewer {
private containerName: string;
private map: Microsoft.Maps.Map;
constructor(theContainerName: string) {
this.containerName = theContainerName;
this.map = new Microsoft.Maps.Map(document.getElementById(this.containerName));
}
}
测试 (MapViewerTest.ts)
///<reference path="../../lib/jasmine/jasmine.d.ts"/>
///<reference path="../../../FrontEndTools.WebUI/Services/MapViewer.ts"/>
module Viewers {
describe("MapViewer tests",() => {
var viewer = null;
beforeEach(() => {
viewer = new MapViewer("myMapContainer");
});
it("should have a map",() => {
var result = viewer;
expect(result);
});
});
}
运行测试导致错误:“MapViewer 测试:应该有地图”失败 ReferenceError:找不到变量:Microsoft in file://.../_Chutzpah.83.MapViewer.js。
顺便说一句,jQuery CDN 作为参考路径工作得很好。对包含 jQuery 的源的测试成功运行。
Chutzpah.json
{
"Framework": "jasmine",
"TestHarnessReferenceMode": "Normal",
"TypeScriptModuleKind": "CommonJS",
"TypeScriptCodeGenTarget": "ES5",
"References" : [
{ "Path": "FrontEndTools.WebUI/lib/knockout.js" },
{ "Path": "http://code.jquery.com/jquery-2.1.0.min.js" },
{ "Path": "http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" }
]
}
【问题讨论】:
标签: javascript typescript bing-maps chutzpah