Add label printing functionality and error handling in stock and label flows
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { formatPrintErrorMessage } from '../../src/api/labels.js';
|
||||
|
||||
describe('api/labels formatPrintErrorMessage', () => {
|
||||
it('maps printer_unavailable payload to user-friendly message', () => {
|
||||
const message = formatPrintErrorMessage({
|
||||
status: 503,
|
||||
payload: {
|
||||
code: 'printer_unavailable',
|
||||
message: 'Backend says unavailable',
|
||||
details: { printer: 'Office Zebra' },
|
||||
},
|
||||
});
|
||||
|
||||
expect(message).toBe('Printer is unavailable. (printer: Office Zebra)');
|
||||
});
|
||||
|
||||
it('falls back to generic message when payload is missing', () => {
|
||||
const message = formatPrintErrorMessage(new Error('Something failed'));
|
||||
expect(message).toBe('Something failed');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user