Skip to content

Commit 3aa5ba6

Browse files
authored
Merge pull request #1594 from commercetools/fix-empty-categoryOrderHints
test(sync-actions): add test for empty categoryOrderHints
2 parents 739f1cb + 07885fb commit 3aa5ba6

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/sync-actions/src/product-actions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ export function actionsMapCategories(diff) {
490490

491491
export function actionsMapCategoryOrderHints(diff) {
492492
if (!diff.categoryOrderHints) return []
493+
// Ignore this pattern as its means no changes happened [{},0,0]
494+
if (Array.isArray(diff.categoryOrderHints)) return []
493495

494496
return Object.keys(diff.categoryOrderHints).map((categoryId) => {
495497
const hintChange = diff.categoryOrderHints[categoryId]

packages/sync-actions/test/product-sync-base.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,30 @@ describe('Actions', () => {
288288
])
289289
})
290290

291+
test('shouldnt generate any categoryOrderHints actions', () => {
292+
const before = {
293+
categoryOrderHints: {},
294+
}
295+
296+
const now = {}
297+
298+
const actions = productsSync.buildActions(now, before)
299+
300+
expect(actions).toEqual([])
301+
})
302+
303+
test('shouldnt generate any searchKeywords actions', () => {
304+
const before = {
305+
searchKeywords: {},
306+
}
307+
308+
const now = {}
309+
310+
const actions = productsSync.buildActions(now, before)
311+
312+
expect(actions).toEqual([])
313+
})
314+
291315
test('should build base actions for long diff text', () => {
292316
const longText = `
293317
Lorem ipsum dolor sit amet, consectetur adipiscing elit.

0 commit comments

Comments
 (0)