我正在寻找一种通过茉莉花测试我的角度分量函数的方法,但不知道如何检查简单的切换功能


showUserInfo(id: number) {
this.usuarioSelecionado = id;
this.mostrarConteudo = this.mostrarConteudo ? false : true;
}

我在规范中这样做,试图传递一个布尔值,但没有成功:

it('show more informations about the user', () => {
expect(this.component.mostrarUsuarioInfo(this.id)).toBe('true')
});

toBe('true')不检查boolean值,而是检查值为"true"string。要检查布尔值,请删除撇号。

it('show more informations about the user', () => {
expect(this.component.mostrarUsuarioInfo(this.id)).toBe(true);
});

最新更新