小编cpa*_*ter的帖子

测试期间 ng-reflect 与 nativeElement 上的“real”属性值

我尝试用 karma/jasmine nut 测试 angular4/5 中的自定义输入元素,我不知道我是否错过了什么。

有人能指出我正确的方向吗?

所以我有一个自定义输入组件,例如:

<div>
  <input class="input-class" [type]="inputType" [required]="required" [disabled]="disabled"          [(ngModel)]="value" (input)="handleChange()" />
  <label>...</label>
</div>
Run Code Online (Sandbox Code Playgroud)

现在我想测试 nativeElement 上的禁用属性,例如:

it('can be disabled', () => {
formControl.disable();
    let inputElement = fixture.debugElement.query(By.css('input-element'))
    fixture.detectChanges();
    // works:
    expect(inputElement.attributes.getNamedItem('ng-reflect-is-disabled')).toBeTruthy();
    // works not:
    expect(inputElement.disabled).toBeTruthy();   
    // also doesn't work:
    expect(inputElement.attributes.getNamedItem('disabled')).toBeTruthy();
  });
Run Code Online (Sandbox Code Playgroud)

为什么我可以看到 ng-reflect 属性的更改,但看不到原始属性的更改?我是否错过了触发生命周期事件的调用?O 我必须使用量角器测试吗?

testing karma-jasmine angular

7
推荐指数
1
解决办法
6896
查看次数

HttpServlet生命周期和序列化

我想知道在反序列化之后是否调用了HttpServlet的init方法.

我不知道是否有任何容器序列化servlet但它实现了Serializable接口,因此有可能这样做.

init方法的JavaDoc指出:"由servlet容器调用,以向servlet指示servlet正在投入服务."

反序列化是否等于"投入使用"?

lifecycle serialization servlets init

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