- Delete unused dataMerger, formatter, Device model, dead service exports, and the empty agents/ + .gitkeep placeholders. - Extract STORE_MODES and MDM device-type filters into a shared constants.js. - Anchor bot regexes (^help|^store|^analyze) so "analyze store 305" no longer fires both handlers; replace catch-all noise. - Hoist inline require() calls in integrations to top-of-file imports. - Harden WebSocket server: Authorization header support, single-agent enforcement, bounded pending requests, server-level error handler, coalesced cache refresh in Meraki client. - Wrap Meraki/MDM network calls with withRetry; add request timeouts. - Migrate all console.* calls onto utils/logger.js (LOG_LEVEL aware); drive Webex framework logLevel from env. - Refactor storeDetail.js: shared renderClientLine + buildMdmSection helpers cut duplication roughly in half. - Refresh README structure, document LOG_LEVEL, add npm run agent script, add jest testMatch + new tests (handlers, HealthReport, Store, ws). Verified: npm run lint clean, 7 suites / 31 tests passing. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
982 B
JavaScript
28 lines
982 B
JavaScript
const { parseStoreNumber } = require('../utils/validate');
|
|
|
|
describe('parseStoreNumber', () => {
|
|
it('extracts a simple store number', () => {
|
|
expect(parseStoreNumber('store 782')).toBe('782');
|
|
expect(parseStoreNumber('analyze 305')).toBe('305');
|
|
});
|
|
|
|
it('handles numbers with surrounding text', () => {
|
|
expect(parseStoreNumber('please analyze store 1234 now')).toBe('1234');
|
|
});
|
|
|
|
it('returns null for invalid input', () => {
|
|
expect(parseStoreNumber(null)).toBeNull();
|
|
expect(parseStoreNumber('')).toBeNull();
|
|
expect(parseStoreNumber('store abc')).toBeNull();
|
|
expect(parseStoreNumber('store 0')).toBeNull();
|
|
expect(parseStoreNumber('store -42')).toBeNull();
|
|
});
|
|
|
|
it('ignores numbers that are too long', () => {
|
|
expect(parseStoreNumber('store 12345678901')).toBeNull(); // 11 digits
|
|
});
|
|
|
|
it('normalizes by removing leading zeros in result (via parseInt)', () => {
|
|
expect(parseStoreNumber('store 00042')).toBe('42');
|
|
});
|
|
});
|