bmc_hub/tests/js/company-contacts.test.cjs
Christian 4871dd2d9e Add comprehensive test coverage for various modules
- Introduced tests for mail templates including ranking, rendering, and attachment handling.
- Added tests for time billing selection and approval processes, ensuring proper validation and state management.
- Implemented tests for case types in JavaScript, focusing on loading and editing functionality.
- Created tests for contact mail AI integration, ensuring proper parsing and error handling.
- Developed tests for dark theme CSS contrast and loading order.
- Added tests for invoice fee service, covering various scenarios including exemptions and invalid inputs.
- Implemented vendor resource tests, ensuring proper file handling and query validation.
2026-10-08 08:58:02 +02:00

11 lines
1.1 KiB
JavaScript

const assert=require('node:assert/strict');global.window={};require('../../static/js/company-contacts.js');
const helpers={name:c=>`${c.first_name} ${c.last_name}`,phone:c=>c.phone||'',mobile:c=>c.mobile||'',actions:()=>''};
const contacts=[{id:1,first_name:'Ida',last_name:'Hansen',email:'ida@example.com',title:'Support',phone:'12345678',is_primary:true},{id:2,first_name:'Poul',last_name:'Larsen',title:'Salg'}];
assert.equal(window.CompanyContacts.filter(contacts,'support',false,helpers).length,1);
assert.equal(window.CompanyContacts.filter(contacts,'',true,helpers).length,1);
assert.equal(window.CompanyContacts.filter(contacts,'',false,helpers).length,2);
const malicious={id:3,first_name:'<script>',email:'a" onclick="bad',phone:'12" onclick="bad'};
const html=window.CompanyContacts.table(window.CompanyContacts.rows([...contacts,malicious],helpers));
assert(html.includes('Primær'));assert(html.includes('Mobil'));assert(html.includes('/contacts/1'));assert(!html.includes('<script>'));assert(!html.includes('href="mailto:a" onclick='));assert(!html.includes('href="tel:12" onclick='));
console.log('Shared customer/vendor contact table checks passed');