Skip to content

Commit

Permalink
test(product): fix variant mapping test
Browse files Browse the repository at this point in the history
  • Loading branch information
Siilwyn committed Oct 27, 2016
1 parent 98a8852 commit 3902100
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/spec/sync/inventory-sync.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe 'InventorySync', ->

update = @sync.buildActions(ieNew, ieOld).getUpdatePayload()
expect(update.actions[0].action).toBe 'setCustomType'
expect(update.actions[0].type).toEqual { typeId : 'type', id : '123' }
expect(update.actions[0].type).toEqual { typeId: 'type', id: '123' }
expect(update.actions[0].fields).toEqual { nac: 'ho' }

it 'should update custom type', ->
Expand All @@ -143,7 +143,7 @@ describe 'InventorySync', ->

update = @sync.buildActions(ieNew, ieOld).getUpdatePayload()
expect(update.actions[0].action).toBe 'setCustomType'
expect(update.actions[0].type).toEqual { typeId : 'type', id : '123' }
expect(update.actions[0].type).toEqual { typeId: 'type', id: '123' }

it 'should update custom fields', ->
ieOld =
Expand Down
17 changes: 3 additions & 14 deletions src/spec/sync/product-sync.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,17 @@ describe 'ProductSync', ->
oldProduct =
id: '123'
version: 1
masterVariant:
id: 1
sku: 'v1'
attributes: [{name: 'foo', value: 'bar'}]
variants: [
{ id: 2, sku: 'v2', attributes: [{name: 'foo', value: 'qux'}] }
{ id: 3, sku: 'v3', attributes: [{name: 'foo', value: 'baz'}] }
]
variants: []

newProduct =
id: '123'
variants: [
{ id: 2, sku: 'v2', attributes: [{name: 'foo', value: 'another value'}] }
{ id: 3, sku: 'v4', attributes: [{name: 'foo', value: 'i dont care'}] }
{ id: 4, sku: 'v3', attributes: [{name: 'foo', value: 'yet another'}] }
{ id: 2, sku: 'v2', attributes: [{name: 'foo', value: 'new variant'}] }
]
update = @sync.buildActions(newProduct, oldProduct).getUpdatePayload()
expected_update =
actions: [
{ action: 'setAttribute', variantId: 2, name: 'foo', value: 'another value' }
{ action: 'setAttribute', variantId: 3, name: 'foo', value: 'yet another' }
{ action: 'addVariant', sku: 'v4', attributes: [{ name: 'foo', value: 'i dont care' }] }
{ action: 'addVariant', sku: 'v2', attributes: [{ name: 'foo', value: 'new variant' }] }
]
version: oldProduct.version
expect(update).toEqual expected_update

0 comments on commit 3902100

Please sign in to comment.