我正在阅读单元测试时遇到一些困难,这个单元测试正在读取一些用*ngIf从DOM中添加/删除的html.
这是DOM:
<div class="detailacc" (click)="showDet()">
<i class="fa" [class.fa-caret-right]="!showHideDet " [class.fa-caret-down]="showHideDet " aria-hidden="true"></i>
<h4>Expandable</h4>
</div>
<div *ngIf="showHideDet">
<p class="detailHeader">Details header</p>
</div>
Run Code Online (Sandbox Code Playgroud)
这是在第一个div的click事件中调用的组件函数:
private showDet() {
console.log('show called');
this.showHideDet = !this.showHideDet;
}
Run Code Online (Sandbox Code Playgroud)
最后这是规范:
it('should show the header when the expandable elem is clicked', async(() =>
{
const fixture = TestBed.createComponent(DetailsComponent);
const compiled = fixture.debugElement.nativeElement;
let detPresent: boolean = false;
for (let node of compiled.querySelectorAll('.detailacc')) {
node.click();
}
setTimeout(() => {
console.log(compiled.querySelectorAll('.detailHeader'));
for (let node of compiled.querySelectorAll('.detailHeader')) {
if (node.textContent === 'Details header') …Run Code Online (Sandbox Code Playgroud) 我注意到RxJS中没有实现发布主题.有没有办法模拟类似的东西?我想只收到订阅后发送的数据,没有最后一个值.完全是角度为2的事件发射器的行为.所有其他主题类型似乎存储最后一个值并发送它.
带着敬意
我正在尝试实现我们在数值方法类中所做的算法.我有一个用Maple编写的相同程序,它工作正常.我不明白为什么它不能在C++中工作.
任何帮助或提示将不胜感激; 提前致谢.
#include "stdafx.h"
#include "math.h"
#include <iostream>
using namespace std;
double absval(double val)
{
if (val >= 0) return val;
else return -val;
}
double G(double x)
{
double g;
g = 1/((x*x)+12);
return g;
}
int main()
{
double c = 0.011834; /* constant */
double eps = 0.00001; /* precision */
double x0 = 0; /* initial aproximation */
double x1,x2,c1;
int i,no;
i = 1;
cout << "enter max nr of iterations ";
cin >> …Run Code Online (Sandbox Code Playgroud)