尝试情况下的角度测试用例

时间:2020-09-30 05:51:33

标签: angular unit-testing testcase angular-test angular-testing

我具有下面的函数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');
    }   
}

0 个答案:

没有答案
相关问题