Skip to content

Commit 6d5178b

Browse files
committed
feat: add testMode as an alias to skipDomainVerification
1 parent 7039d7c commit 6d5178b

3 files changed

Lines changed: 48 additions & 6 deletions

File tree

‎src/defaults.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export default {
55
debug: false,
66
locale: settings.locales.EN_US,
77
skipDomainVerification: false,
8+
testMode: false,
89
timeout: 30000, // 30 seconds
910
};

‎src/embedded.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@ class HelloSign extends Emitter {
320320
* Validates and appends the "skip_domain_verification"
321321
* parameter to the iFrame params object.
322322
*
323-
* @throws {TypeError} if skipDomainVerification is invalid
323+
* @throws {TypeError} if testMode is invalid
324324
* @param {URLSearchParams} params
325325
* @private
326326
*/
327-
_applySkipDomainVerification(params) {
328-
const val = this._config.skipDomainVerification;
327+
_applyTestMode(params) {
328+
const val = this._config.skipDomainVerification || this._config.testMode;
329329

330330
if (typeof val !== 'boolean') {
331-
throw new TypeError('"skipDomainVerification" must be a boolean');
331+
throw new TypeError('"testMode" must be a boolean');
332332
}
333333

334334
params.append('skip_domain_verification', val ? 1 : 0);
@@ -394,7 +394,7 @@ class HelloSign extends Emitter {
394394
this._applyParentURL(params);
395395
this._applyRedirectTo(params);
396396
this._applyRequestingEmail(params);
397-
this._applySkipDomainVerification(params);
397+
this._applyTestMode(params);
398398
this._applyUxVersion(params);
399399
this._applyVersion(params);
400400
this._applyWhiteLabeling(params);
@@ -996,6 +996,7 @@ class HelloSign extends Emitter {
996996
* @property {string} [redirectTo]
997997
* @property {string} [requestingEmail]
998998
* @property {boolean} [skipDomainVerification=false]
999+
* @property {boolean} [testMode=false]
9991000
* @property {number} [timeout=30000]
10001001
* @property {Object} [whiteLabeling]
10011002
*/

‎src/embedded.test.js‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ describe('HelloSign', () => {
428428
client.open(mockSignURL, {
429429
skipDomainVerification: 42,
430430
});
431-
}).toThrow(/"skipDomainVerification" must be a boolean/);
431+
}).toThrow(/"testMode" must be a boolean/);
432432
});
433433

434434
test('appends default value for "skip_domain_verification" to the iFrame URL if "skipDomainVerification" is not specified', (done) => {
@@ -461,6 +461,46 @@ describe('HelloSign', () => {
461461
});
462462
});
463463

464+
test('throws if "testMode" is not a boolean', () => {
465+
client = new HelloSign({ clientId: mockClientId });
466+
467+
expect(() => {
468+
client.open(mockSignURL, {
469+
testMode: 42,
470+
});
471+
}).toThrow(/"testMode" must be a boolean/);
472+
});
473+
474+
test('appends default value for "skip_domain_verification" to the iFrame URL if "testMode" is not specified', (done) => {
475+
client = new HelloSign({ clientId: mockClientId });
476+
477+
client.on(HelloSign.events.OPEN, (data) => {
478+
const url = new URL(data.url);
479+
480+
expect(url.searchParams.has('skip_domain_verification')).toBe(true);
481+
expect(url.searchParams.get('skip_domain_verification')).toBe('0');
482+
done();
483+
});
484+
485+
client.open(mockSignURL);
486+
});
487+
488+
test('appends "skip_domain_verification" to the iFrame URL if "testMode" is valid', (done) => {
489+
client = new HelloSign({ clientId: mockClientId });
490+
491+
client.on(HelloSign.events.OPEN, (data) => {
492+
const url = new URL(data.url);
493+
494+
expect(url.searchParams.has('skip_domain_verification')).toBe(true);
495+
expect(url.searchParams.get('skip_domain_verification')).toBe('1');
496+
done();
497+
});
498+
499+
client.open(mockSignURL, {
500+
testMode: true,
501+
});
502+
});
503+
464504
test('throws if "whiteLabeling" is not an object', () => {
465505
client = new HelloSign({ clientId: mockClientId });
466506

0 commit comments

Comments
 (0)