我正在寻找一种通过 jasmine 测试我的 angular 组件功能的方法,但不知道如何检查简单的切换功能
I'm looking for a way to test my angular component function through jasmine, but have no idea how to check a simply toggle funcion
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
值,而是检查 string
值 "true"
。为了检查布尔值,删除撇号。
it('show more informations about the user', () => {
expect(this.component.mostrarUsuarioInfo(this.id)).toBe(true);
});
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
值,而是检查 string
值 "true"
。为了检查布尔值,删除撇号。
it('show more informations about the user', () => {
expect(this.component.mostrarUsuarioInfo(this.id)).toBe(true);
});