mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[UXP-10] typdocs and tests
This commit is contained in:

committed by
Sufiyan Shaikh

parent
0783cd5cb6
commit
4906516359
32
src/app/core/data/google-recaptcha.service.spec.ts
Normal file
32
src/app/core/data/google-recaptcha.service.spec.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { GoogleRecaptchaService } from './google-recaptcha.service';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
describe('GoogleRecaptchaService', () => {
|
||||
let service: GoogleRecaptchaService;
|
||||
|
||||
let reCaptchaV3Service;
|
||||
|
||||
function init() {
|
||||
reCaptchaV3Service = jasmine.createSpyObj('reCaptchaV3Service', {
|
||||
execute: observableOf('googleRecaptchaToken')
|
||||
});
|
||||
service = new GoogleRecaptchaService(reCaptchaV3Service);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
init();
|
||||
});
|
||||
|
||||
describe('getRecaptchaToken', () => {
|
||||
let result;
|
||||
|
||||
beforeEach(() => {
|
||||
result = service.getRecaptchaToken('test');
|
||||
});
|
||||
|
||||
it('should send a Request with action', () => {
|
||||
expect(reCaptchaV3Service.execute).toHaveBeenCalledWith('test');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
@@ -1,6 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ReCaptchaV3Service } from 'ng-recaptcha';
|
||||
|
||||
/**
|
||||
* A GoogleRecaptchaService used to send action and get a token from REST
|
||||
*/
|
||||
@Injectable()
|
||||
export class GoogleRecaptchaService {
|
||||
|
||||
@@ -8,6 +11,10 @@ export class GoogleRecaptchaService {
|
||||
private recaptchaV3Service: ReCaptchaV3Service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Returns an observable of string
|
||||
* @param action action is the process type in which used to protect multiple spam REST calls
|
||||
*/
|
||||
public getRecaptchaToken (action) {
|
||||
return this.recaptchaV3Service.execute(action);
|
||||
}
|
||||
|
Reference in New Issue
Block a user