import { normalizeScreen } from './tbank-screen'; describe('manual sync screen boundary', () => { it('normalizes equivalent descriptors to the same scope', () => { expect(normalizeScreen({ screen: 'stocks', query: ' sber ' })).toEqual({ screen: 'stocks', query: 'SBER', }); expect( JSON.stringify( normalizeScreen({ screen: 'operations', accountId: 'a', categories: ['tax', 'income', 'tax'], limit: 20, }), ), ).toBe( JSON.stringify( normalizeScreen({ limit: 20, categories: ['income', 'tax'], accountId: 'a', screen: 'operations', }), ), ); }); it('rejects missing identities and fields that would expand another screen', () => { for (const scope of [ { screen: 'accounts', accountId: 'a' }, { screen: 'account' }, { screen: 'stock' }, { screen: 'stocks', query: ' ' }, { screen: 'events', accountId: 'a', instrumentUid: 'uid' }, { screen: 'income', accountId: 'a', from: '2026-01-01' }, { screen: 'events', accountId: 'a', from: '2026-02-01', to: '2026-01-01', }, ] as Parameters[0][]) expect(() => normalizeScreen(scope)).toThrow(); }); it('retains inclusive calendar days, rejecting instant values for date-only owners', () => { const scope = { screen: 'events' as const, accountId: 'all', from: '2026-01-01', to: '2026-01-01', }; expect(normalizeScreen(scope)).toEqual(scope); expect(() => normalizeScreen({ ...scope, from: '2026-01-01T00:00:00Z' }), ).toThrow(); expect(() => normalizeScreen({ screen: 'stock', instrumentUid: 'uid', candleRange: { from: '2026-01-02', to: '2026-01-01' }, }), ).toThrow(); }); });