Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Add action parameter for v3 execution. #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,13 @@

/**
* Executes the reCaptcha
* @param widgetId
* @param [action] the action for reCAPTCHA v3
*/
execute: function (widgetId) {
execute: function (widgetId, action) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recaptcha expects that the provided action is a string. Do we know that it tollerates undefined ?

validateRecaptchaInstance();

recaptcha.execute(widgetId);
recaptcha.execute(widgetId, {action: action});
},

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/service_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ describe('service', function () {
it('should call execute', function () {
var _widgetId = 123;

driver.service.execute(_widgetId);
driver.service.execute(_widgetId, 'my-action');

expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId);
expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId, {action: 'my-action'});
});

it('should call getResponse', function () {
Expand Down Expand Up @@ -163,9 +163,9 @@ describe('service', function () {

var _widgetId = 123;

driver.service.execute(_widgetId);
driver.service.execute(_widgetId, 'my-action');

expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId);
expect(grecaptchaMock.execute).toHaveBeenCalledWith(_widgetId, {action: 'my-action'});
});

it('should not proceed if render function not available in grecaptcha', function () {
Expand Down