小编GHB*_*GHB的帖子

angular2:如何测试具有可观察时间间隔的组件

我有一个幻灯片放映组件,它有一个幻灯片对象的输入数组,只要它slide.time本身被定义,就会显示每个对象.还有两个点击它们的按钮必须滑动到下一个项目并重置计时器.为了使这项工作,我正在使用这样的Observable:

/**
 * a "SUBJECT" for pausing(restarting) the slider's auto-slide on user's click on left and right arrows
 * @type {Subject}
 */
private pauser = new Subject();

/**
 * the main observable for timer (before adding the pause/reset option)
 * @type {Observable<T>}
 */
private source = Observable
    .interval(1000)
    .timeInterval()
    .map(function (x) { /*return x.value + ':' + x.interval;*/ return x })
    .share();

/**
 * the final timer, which can be paused
 * @type {Observable<R>}
 */
private pausableSource = …
Run Code Online (Sandbox Code Playgroud)

unit-testing observable rxjs karma-jasmine angular

6
推荐指数
1
解决办法
1984
查看次数

标签 统计

angular ×1

karma-jasmine ×1

observable ×1

rxjs ×1

unit-testing ×1