/** * Captcha Component Unit Tests */ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ReCaptchaComponent, ReCaptchaModule } from 'angular2-recaptcha'; import { RecaptchaResponse } from '../../models/recaptcha/recaptchaResponse'; import { CaptchaComponent } from './captcha.component'; describe('Captcha Component', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ CaptchaComponent ], imports: [ ReCaptchaModule ], }); }); it('captcha component should exist', () => { const fixture = TestBed.createComponent(CaptchaComponent); const comp = fixture.componentInstance; expect(comp).toBeDefined(); }); it('should return captcha response', () => { const fixture = TestBed.createComponent(CaptchaComponent); const comp = fixture.componentInstance; comp.handleCorrectCaptcha('abcdefgh'); expect(comp.recaptchaResponse.response.length).toBeGreaterThan(0); }); it('should set flag when captcha expires', () => { const fixture = TestBed.createComponent(CaptchaComponent); const comp = fixture.componentInstance; comp.captchaExpired(); expect(comp.recaptchaResponse.isExpired).toBeTruthy(); }); });