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);
});