angular - 我正在寻找一种通过茉莉花测试我的角度组件功能的方法,但不知道如何检查简单的切换功能
问题描述
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
value 而是检查 a string
of value "true"
。为了检查布尔值,删除撇号。
it('show more informations about the user', () => {
expect(this.component.mostrarUsuarioInfo(this.id)).toBe(true);
});
推荐阅读
- amazon-web-services - 在 AWS(架构)中查找与特定用户相关的所有数据
- php - PHP 警告:PHP 启动:无法加载动态库“redis.so”
- log4j2 - Log4j2 的 json 配置中包的不同日志记录级别
- python - 为什么 PyCharm 在 input() 和 print() 函数中给出错误 - “未解决的参考”?
- ruby-on-rails - 如何调试 RocketChat 错误不允许(尝试邀请和添加/删除所有者)
- tensorflow - TFLiteConverter 来自 keras.preprocessing.image_dataset_from_directory 数据集的代表数据集
- flutter - FormatException:意外字符(在字符 1 处),这是我在解码我的 json 格式时发生的错误
- c# - chart.js 中是否有一个选项可以隐藏图表图例中的值
- erlang - Erlang/Akka 等如何在后台发送消息?为什么不会导致死锁?
- javascript - 使用 js 和 symfony 操作复选框