我具有下面的函数initializeConnetion()
,在其中初始化和建立连接。
另外,我还有另一个功能showOtherInformation()
,在编写功能主体之前,请确保已建立连接。
我想为此编写测试用例。
initializeConnetion() {
try {
if(!this.connection) {
this.connection = (window as any).parent.connectionFramework;
this.metaInfo = this.connection.getMetaInfo();
}
} catch(error) {
connectionFailed(error, 'Could Initialize connection');
}
}
showOtherInformation() {
try {
initializeConnetion();
if(this.connection) {
this.connection.showOtherInfo('Data to be shown', {visibility: true});
}
} catch(error) {
connectionFailed(error, 'Could Initialize connection');
}
}