Skip to content

Commit

Permalink
fix(productSync): Fix product sync update key and variantKey action
Browse files Browse the repository at this point in the history
  • Loading branch information
junajan committed Aug 28, 2017
1 parent 45ffc1d commit 68dbb96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/coffee/sync/utils/product.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ class ProductUtils extends BaseUtils
if _.has variantDiff, 'key'
action =
action: 'setProductVariantKey'
sku: old_variant.sku
variantId: old_variant.id
key: @getDeltaValue(variantDiff.key)

module.exports = ProductUtils
Expand Down
12 changes: 8 additions & 4 deletions src/spec/sync/utils/product.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -900,18 +900,22 @@ describe 'ProductUtils', ->
OLD =
id: '123'
masterVariant:
id: 1
sku: 'masterSku'
key: 'oldKey'
variants: [
{
id: 2
sku: 'variantSku'
key: 'oldVariantKey'
},
{
id: 3
sku: 'variantSku2'
key: 'oldVariantKey2'
},
{
id: 4
sku: 'variantSku3'
}
]
Expand Down Expand Up @@ -939,10 +943,10 @@ describe 'ProductUtils', ->
update = @utils.actionsMapAttributes delta, OLD, NEW

expected_update = [
{ action: 'setProductVariantKey', sku: 'masterSku', key: 'newKey' }
{ action: 'setProductVariantKey', sku: 'variantSku', key: 'newVariantKey' }
{ action: 'setProductVariantKey', sku: 'variantSku2', key: undefined }
{ action: 'setProductVariantKey', sku: 'variantSku3', key: 'newVariantKey3' }
{ action: 'setProductVariantKey', variantId: 1, key: 'newKey' }
{ action: 'setProductVariantKey', variantId: 2, key: 'newVariantKey' }
{ action: 'setProductVariantKey', variantId: 3, key: undefined }
{ action: 'setProductVariantKey', variantId: 4, key: 'newVariantKey3' }
]
expect(update).toEqual expected_update

Expand Down

0 comments on commit 68dbb96

Please sign in to comment.