All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m18s
51 lines
1.9 KiB
JavaScript
51 lines
1.9 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const test = require('node:test');
|
|
|
|
const {
|
|
normalizeFamilyKey,
|
|
normalizeFamilyYields,
|
|
normalizeProductType,
|
|
normalizeProductOverrides
|
|
} = require('../services/cuttingSettingsService');
|
|
|
|
test('normalizeFamilyKey accepts only known cut families', () => {
|
|
assert.equal(normalizeFamilyKey('blcs'), 'BLCS');
|
|
assert.equal(normalizeFamilyKey(' BLOS '), 'BLOS');
|
|
assert.equal(normalizeFamilyKey('OUTROS'), '');
|
|
assert.equal(normalizeFamilyKey('unknown'), '');
|
|
});
|
|
|
|
test('normalizeFamilyYields keeps positive numeric yield rules', () => {
|
|
assert.deepEqual(normalizeFamilyYields({
|
|
BLCS: '50',
|
|
BLOS: 0,
|
|
BLMC: -1,
|
|
BLPM: '12.5',
|
|
OUTROS: 99
|
|
}), {
|
|
BLCS: 50,
|
|
BLPM: 12.5
|
|
});
|
|
});
|
|
|
|
test('normalizeProductType accepts only known planning product types', () => {
|
|
assert.equal(normalizeProductType('finished_apparel'), 'finished_apparel');
|
|
assert.equal(normalizeProductType('raw_material'), 'raw_material');
|
|
assert.equal(normalizeProductType('finished_product'), '');
|
|
assert.equal(normalizeProductType('unknown type'), '');
|
|
});
|
|
|
|
test('normalizeProductOverrides trims and removes empty overrides', () => {
|
|
assert.deepEqual(normalizeProductOverrides({
|
|
' SKU-1 ': { familyKey: 'blcs', color: ' Preto ', size: ' m ', productType: 'finished_apparel', planningNotes: ' revisar corte ' },
|
|
'SKU-2': { familyKey: 'OUTROS', color: '', size: '' },
|
|
'SKU-3': { familyKey: '', color: ' Branco ', size: '' },
|
|
'SKU-4': { productType: 'raw_material' },
|
|
'SKU-5': null
|
|
}), {
|
|
'SKU-1': { familyKey: 'BLCS', color: 'Preto', size: 'M', productType: 'finished_apparel', planningNotes: 'revisar corte' },
|
|
'SKU-3': { familyKey: '', color: 'Branco', size: '', productType: '', planningNotes: '' },
|
|
'SKU-4': { familyKey: '', color: '', size: '', productType: 'raw_material', planningNotes: '' }
|
|
});
|
|
});
|