用茉莉花角测试“ this”

时间:2018-11-23 03:25:00

标签: angularjs testing jasmine

我想用茉莉花做一个测试代码,像这样的代码:

  toggle(id) {
    this.selected = id;
    this.show2 = !this.show2;
  }

这是我的测试功能:

  test('test toogle function', () => {
    const spy = spyOn(component, 'toggle')
    expect(spy).toHaveBeenCalled();
  })

当我尝试进行测试但只切换(id)时 经过测试并通过覆盖 和toggle(id)中的功能未经测试,如何测试toggle(id)中的功能?

谢谢

0 个答案:

没有答案