sms-compliance-supplement2.test.js
1 /** 2 * SMS Compliance Supplement 2 - Coverage for uncovered paths 3 * Covers: requiresTcpaCompliance(null), prohibitsPromotionalLanguage, getSmsEnderId 4 */ 5 6 import { test } from 'node:test'; 7 import assert from 'node:assert'; 8 9 import { 10 requiresTcpaCompliance, 11 prohibitsPromotionalLanguage, 12 getSmsEnderId, 13 } from '../../src/utils/sms-compliance.js'; 14 15 test('requiresTcpaCompliance returns false for null', () => { 16 assert.strictEqual(requiresTcpaCompliance(null), false); 17 }); 18 19 test('requiresTcpaCompliance returns false for undefined', () => { 20 assert.strictEqual(requiresTcpaCompliance(undefined), false); 21 }); 22 23 test('requiresTcpaCompliance returns false for empty string', () => { 24 assert.strictEqual(requiresTcpaCompliance(''), false); 25 }); 26 27 test('prohibitsPromotionalLanguage delegates to requiresTcpaCompliance for US', () => { 28 assert.strictEqual(prohibitsPromotionalLanguage('US'), true); 29 }); 30 31 test('prohibitsPromotionalLanguage delegates to requiresTcpaCompliance for AU', () => { 32 assert.strictEqual(prohibitsPromotionalLanguage('AU'), false); 33 }); 34 35 test('prohibitsPromotionalLanguage returns false for null', () => { 36 assert.strictEqual(prohibitsPromotionalLanguage(null), false); 37 }); 38 39 test('getSmsEnderId uses SENDER_NAME and SENDER_COMPANY env vars', () => { 40 process.env.SENDER_NAME = 'Mike'; 41 process.env.SENDER_COMPANY = 'Audit&Fix'; 42 const id = getSmsEnderId(); 43 assert.strictEqual(id, '-Mike, Audit&Fix'); 44 }); 45 46 test('getSmsEnderId strips Pty Ltd from company name', () => { 47 process.env.SENDER_NAME = 'Jane'; 48 process.env.SENDER_COMPANY = 'WebCo Pty Ltd'; 49 const id = getSmsEnderId(); 50 assert.strictEqual(id, '-Jane, WebCo'); 51 }); 52 53 test('getSmsEnderId strips LLC from company name', () => { 54 process.env.SENDER_NAME = 'Bob'; 55 process.env.SENDER_COMPANY = 'Designs LLC'; 56 const id = getSmsEnderId(); 57 assert.strictEqual(id, '-Bob, Designs'); 58 }); 59 60 test('getSmsEnderId strips Inc from company name', () => { 61 process.env.SENDER_NAME = 'Sarah'; 62 process.env.SENDER_COMPANY = 'Tech Inc'; 63 const id = getSmsEnderId(); 64 assert.strictEqual(id, '-Sarah, Tech'); 65 }); 66 67 test('getSmsEnderId uses defaults when env vars not set', () => { 68 delete process.env.SENDER_NAME; 69 delete process.env.SENDER_COMPANY; 70 const id = getSmsEnderId(); 71 assert.strictEqual(id, '-Team, Support'); 72 });