使用event.json.valueOf()的角度ts文件,如何从业力进行单元测试

时间:2019-04-04 15:12:09

标签: angular7

如何将输入值传递给“ event.json.valueOf()”,该值在来自业力测试平台的.ts文件中使用。我尝试了以下逻辑,但无法正常工作。我什至尝试传递静态json(reportData)值,但仍然出现错误。

it('onconversion() called', () => {
    // console.log(row)
    const click1 = new Event('click');
    const reportData = {
      'Export Metadata': [
        {
          'Report Id': '1234',
          'Report Name': 'Report Name 1'          
        },
        {
          'Report Id"': '1356',
          'Report Name"': 'Report Name 2'          
        }
      ]
    };

    console.log('**** Before spyOn ****');
    spyOn(component, 'onConversion').and.callThrough();
    console.log('**** Before conversion ****');
    component.onConversion(click1);
    console.log('**** Before expect ****');
    expect(component.onConversion).toHaveBeenCalled();

  });

谢谢。

关于, Sharath。

0 个答案:

没有答案