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 ` 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'); }); });