大佬教程收集整理的这篇文章主要介绍了单元测试 – 如何对Angular2中的复选框进行单元测试,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<div class="col-sm-7 align-left" *ngIf="Some-Condtion"> <input type="check@R_301_2492@" id="mob_Q1" value="Q1" /> <label for="mob_Q1">Express</label> </div>
我想对上面的复选框进行单元测试.就像我想要识别复选框并测试它是否可以检查.我如何用Karma Jasmine进行单元测试?
import {ComponentFixture,TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {Check@R_301_2492@Component} from './check@R_301_2492@.component'; describe('Check@R_301_2492@ test.',() => { let comp: Check@R_301_2492@Component; let fixture: ComponentFixture<Check@R_301_2492@Component>; let input: Element; beforeEach(() => { TestBed.configureTestingModule( { declarations: [Check@R_301_2492@Component],},); fixture = TestBed.createComponent(Check@R_301_2492@Component); comp = fixture.componentInstance; input = fixture.debugElement.query(By.css('#mob_Q1')).nativeElement; }); it('should click change value',() => { expect(input.checked).toBeFalsy(); // default state input.click(); fixture.detectChanges(); expect(input.checked).toBeTruthy(); // state after click }); });
以上是大佬教程为你收集整理的单元测试 – 如何对Angular2中的复选框进行单元测试全部内容,希望文章能够帮你解决单元测试 – 如何对Angular2中的复选框进行单元测试所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。