Skip to content

Commit

Permalink
added testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenAsGrassAP committed Jul 8, 2024
1 parent e649cdb commit 1ab9d99
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/trustedform.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const response = (vars, req, res) => {
page_url: parsed.insights?.properties?.page_url,
parent_page_url: parsed.insights?.properties?.parent_page_url,

languages: parsed.verify?.languages,
languages: parsed.verify?.languages.map(lang => lang.text),
language_approved: parsed.verify?.result?.language_approved,
success: parsed.verify?.result?.success,
}, (v) => { return !isUndefined(v); });
Expand Down
45 changes: 44 additions & 1 deletion test/trustedform_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@ describe('v4', () => {
masked_cert_url: 'https://cert.trustedform-dev.com/f1fd052c43f08078a37d840b243daa69a35e8eda'
},
vendor: 'Inbound Verbose'
},
verify: {
languages: [
{
text: 'I understand that the TrustedForm certificate is sent to the email address I provided above and I will receive product updates as they are released.'
}
],
result: {
language_approved: true,
success: true
}
}
})
};
Expand Down Expand Up @@ -431,7 +442,10 @@ describe('v4', () => {
successful_match: true,
time_on_page_in_seconds: 8374,
time_zone: 'America/Chicago',
vendor: 'Inbound Verbose'
vendor: 'Inbound Verbose',
languages: ['I understand that the TrustedForm certificate is sent to the email address I provided above and I will receive product updates as they are released.'],
language_approved: true,
success: true
};
assert.deepEqual(integration.response({ insights: { page_scan: true }}, {}, res), expected);
});
Expand Down Expand Up @@ -479,6 +493,35 @@ describe('v4', () => {
assert.deepEqual(integration.response({ insights: { page_scan: true }}, {}, res), expected);
});

it('should correctly handle a Verify Consent language failure responses', () => {
const res = {
status: 200,
body: JSON.stringify({
'verify': {
'languages': [
{
'text': 'By clicking on the "Get Rates" button below, I consent to be contacted'
}
],
'result': {
'language_approved': false,
'success': false
}
},
outcome: 'failure',
reason: 'Consent language not detected in the certificate.'
})
};
const expected = {
languages: ['By clicking on the "Get Rates" button below, I consent to be contacted'],
language_approved: false,
success: false,
outcome: 'failure',
reason: 'Consent language not detected in the certificate.',
};
assert.deepEqual(integration.response({}, {}, res), expected);
});

it('should correctly handle an error response', () => {
const res = {
status: 500,
Expand Down

0 comments on commit 1ab9d99

Please sign in to comment.