Files
klz-cables.com/.pnpm-store/v10/files/b1/f141f7a90f39df064c4bbc6efe140f7fd31aaabf297730dcedf14fce0dd80e37f0b39b02b7164b9760f4c2cb84877652f4de18d2a2bb85bb8cec5117a42074
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

135 lines
3.0 KiB
Plaintext

import { describe, it, expect } from 'vitest';
import { getFieldsForRowComparison } from './getFieldsForRowComparison';
describe('getFieldsForRowComparison', () => {
describe('array fields', () => {
it('should return fields from array field', () => {
const arrayFields = [{
name: 'title',
type: 'text'
}, {
name: 'description',
type: 'textarea'
}];
const field = {
type: 'array',
name: 'items',
fields: arrayFields
};
const {
fields
} = getFieldsForRowComparison({
field,
valueToRow: {},
valueFromRow: {},
row: 0,
baseVersionField: {
fields: [],
path: 'items',
schemaPath: 'items',
type: 'array'
},
config: {}
});
expect(fields).toEqual(arrayFields);
});
});
describe('blocks fields', () => {
it('should return combined fields when block types match', () => {
const blockAFields = [{
name: 'a',
type: 'text'
}, {
name: 'b',
type: 'text'
}];
const field = {
type: 'blocks',
name: 'myBlocks',
blocks: [{
slug: 'blockA',
fields: blockAFields
}]
};
const valueToRow = {
blockType: 'blockA'
};
const valueFromRow = {
blockType: 'blockA'
};
const {
fields
} = getFieldsForRowComparison({
field,
valueToRow,
valueFromRow,
row: 0,
baseVersionField: {
fields: [],
path: 'myBlocks',
schemaPath: 'myBlocks',
type: 'blocks'
},
config: {}
});
expect(fields).toEqual(blockAFields);
});
it('should return unique combined fields when block types differ', () => {
const field = {
type: 'blocks',
name: 'myBlocks',
blocks: [{
slug: 'blockA',
fields: [{
name: 'a',
type: 'text'
}, {
name: 'b',
type: 'text'
}]
}, {
slug: 'blockB',
fields: [{
name: 'b',
type: 'text'
}, {
name: 'c',
type: 'text'
}]
}]
};
const valueToRow = {
blockType: 'blockA'
};
const valueFromRow = {
blockType: 'blockB'
};
const {
fields
} = getFieldsForRowComparison({
field,
valueToRow,
valueFromRow,
row: 0,
baseVersionField: {
fields: [],
path: 'myBlocks',
schemaPath: 'myBlocks',
type: 'blocks'
},
config: {}
});
// Should contain all unique fields from both blocks
expect(fields).toEqual([{
name: 'a',
type: 'text'
}, {
name: 'b',
type: 'text'
}, {
name: 'c',
type: 'text'
}]);
});
});
});
//# sourceMappingURL=getFieldsForRowComparison.spec.js.map