This commit is contained in:
@@ -40,3 +40,19 @@ test('rejects unknown or invalid settings', async () => {
|
||||
() => service.update({ sellerId: 'seller-1', settings: { secrets: { token: 'nope' } } }),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
test('seller descriptions are trimmed, bounded, preserved on partial updates and clearable', async () => {
|
||||
let stored;
|
||||
const service = createSellerSettingsService({ sellerSettingsRepository: {
|
||||
async findBySellerId() { return stored; },
|
||||
async upsert(sellerId, settings) { stored = { sellerId, settings }; return stored; },
|
||||
} });
|
||||
const update = (general) => service.update({ sellerId: 'seller-1', settings: { general } });
|
||||
assert.equal((await update({ publicDescription: ' Collector. ' })).general.publicDescription, 'Collector.');
|
||||
assert.equal((await update({ publicContactPhone: '555-0100' })).general.publicDescription, 'Collector.');
|
||||
await assert.rejects(() => update({ publicDescription: 'x'.repeat(2001) }));
|
||||
await assert.rejects(() => update({ publicDescription: 123 }));
|
||||
assert.equal((await update({ publicDescription: 'x'.repeat(2000) })).general.publicDescription.length, 2000);
|
||||
assert.equal((await update({ publicDescription: ' ' })).general.publicDescription, '');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user