小编aks*_*s94的帖子

如何在Angular中创建可观察的模拟来测试http rxjs retry / retryWhen?

我的角度应用程序中有一个这种形式的http请求: this.http.get(url,options).pipe(retry(5))

我想使用茉莉花进行单元测试,以便http请求首先返回一个错误,但在随后的尝试中,返回期望的数据。

I previously returned http errors in this format as recommended by the angular.io documentation spyOn(http,'get').and.returnValue(defer(() => Promise.reject(errorObject)));

The rxjs operator retry does not seem to call the http.get function again, so changing the return value of the spy does not work. What I think I need to do is somehow return an observable from the spy which first emits the error and later emits the data. I thought about using a BehaviorSubject but don't think that accepts …

jasmine rxjs angular

5
推荐指数
1
解决办法
756
查看次数

使用 numberOfLines 道具时,是否可以知道 React Native 渲染了多少行文本?

React Native numberOfLines 道具非常有用,但我想根据实际呈现的文本行数以编程方式调整两个数字之间的行高度。

例如,我有一个这种形式的 Text 组件 <Text numberOfLines={2} ellipsizeMode={'tail'}>{item.text}</Text>

如果文本长于两行,则根据需要默认为两行。但是当它少于两行时,它只显示一行,再次根据需要。我只想知道内容是单留置权还是两行。有什么办法可以找出来吗?

react-native

4
推荐指数
2
解决办法
7701
查看次数

标签 统计

angular ×1

jasmine ×1

react-native ×1

rxjs ×1