我使用的是一个称为内联手册的外部工具,我创建了一项服务并想测试一些功能,但是我真的不知道从这个短代码开始:
Windows引用类:
export class WindowRef {
get nativeWindow(): any {
return window;
}
}
我的服务:
constructor(private httpClient: HttpClient, windowRef: WindowRef) {
this._window = windowRef.nativeWindow;
}
setTracking(trackingData) {
this._window.inlineManualTracking = trackingData;
}
createPlayer() {
const trackingData = this._window.inlineManualPlayerData || null;
try {
this._window.createInlineManualPlayer(trackingData);
} catch (error) {
console.error(error);
}
}
activateTopic(id: string) {
try {
this._window.inline_manual_player.activateTopic(id);
} catch (error) {
console.error(error);
}
}
updatePlayer() {
if (!this._window.inline_manual_player) {
return;
}
try {
this._window.inline_manual_player.update();
} catch (error) {
console.error(error);
}
}
我的规格文件:
it('should set tracking', () => {
//I want to test this functions
});
it('should create player', () => {
});
it('should activate topic', () => {
});
it('should update player', () => {
});