diff --git a/README.md b/README.md index 2543a13..bbef6a4 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,8 @@ The CSV parser does not handle Chinese full-width commas (U+FF0C `,`). See Iss ## Error Handling Added proper timeout handling for all API calls. // Webhook integration implemented + +## Manual Verification + +Issue #40 uses manual verification code `2323`. Run `npm test` to verify the +code path together with the parser regression tests. diff --git a/package.json b/package.json index 6ec1d3f..042676d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A simple CSV parser - BountyPay workflow demo", "main": "src/parser.js", "scripts": { - "test": "node test/parser.test.js" + "test": "node test/parser.test.js && node test/manual-verification.test.js" }, "license": "MIT" } diff --git a/src/manual-verification.js b/src/manual-verification.js new file mode 100644 index 0000000..e31cc1c --- /dev/null +++ b/src/manual-verification.js @@ -0,0 +1,15 @@ +const MANUAL_VERIFICATION_CODE = '2323'; + +function normalizeVerificationCode(value) { + return String(value ?? '').trim(); +} + +function verifyManualCode(value) { + return normalizeVerificationCode(value) === MANUAL_VERIFICATION_CODE; +} + +module.exports = { + MANUAL_VERIFICATION_CODE, + normalizeVerificationCode, + verifyManualCode, +}; diff --git a/test/manual-verification.test.js b/test/manual-verification.test.js new file mode 100644 index 0000000..ed46423 --- /dev/null +++ b/test/manual-verification.test.js @@ -0,0 +1,34 @@ +const { + MANUAL_VERIFICATION_CODE, + normalizeVerificationCode, + verifyManualCode, +} = require('../src/manual-verification'); + +let passed = 0; +let failed = 0; + +function assert(name, actual, expected) { + const a = JSON.stringify(actual); + const e = JSON.stringify(expected); + if (a === e) { + console.log(` OK ${name}`); + passed++; + } else { + console.log(` FAIL ${name}`); + console.log(` Expected: ${e}`); + console.log(` Actual: ${a}`); + failed++; + } +} + +console.log('\nManual Verification Tests\n'); + +assert('documents the issue #40 verification code', MANUAL_VERIFICATION_CODE, '2323'); +assert('accepts the expected verification code', verifyManualCode('2323'), true); +assert('trims whitespace around manual input', verifyManualCode(' 2323 '), true); +assert('rejects an incorrect code', verifyManualCode('2324'), false); +assert('rejects missing input', verifyManualCode(undefined), false); +assert('normalizes null to an empty string', normalizeVerificationCode(null), ''); + +console.log(`\nResults: ${passed} passed, ${failed} failed\n`); +process.exit(failed > 0 ? 1 : 0);