netanalyzer/tests/store.test.js
Joseph McQueen 0a46d25bd6 chore: project cleanup — dead code, logging, tests, WS hardening
- 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>
2026-06-24 17:21:22 -04:00

41 lines
1.2 KiB
JavaScript

const { createStore, Store } = require('../models/Store');
describe('Store model', () => {
it('uses store_number from data when no explicit number given', () => {
const s = createStore({ store_number: '305', name: 'Foo' });
expect(s.number).toBe('305');
expect(s.name).toBe('Foo');
});
it('falls back to `Store <n>` when name is missing', () => {
const s = createStore({}, 42);
expect(s.name).toBe('Store 42');
});
it('handles missing address fields without throwing', () => {
const s = createStore({}, 1);
expect(() => s.toSummary()).not.toThrow();
const summary = s.toSummary();
expect(summary).toContain('Store 1');
expect(summary).toContain('District ID: N/A');
});
it('builds a full address from optional parts', () => {
const s = new Store(
{
address: '123 Main',
address2: 'Suite 5',
city: 'Anytown',
state: 'CA',
postal_code: '90210',
phone: '555-1234',
},
'305'
);
const addr = s.fullAddress;
expect(addr).toContain('123 Main');
expect(addr).toContain('Suite 5');
expect(addr).toContain('Anytown, CA 90210');
expect(addr).toContain('Phone: 555-1234');
});
});