 
 # Increase timeout
 jasmine.getEnv().defaultTimeoutInterval = 10000
+
+getProductFromStaged = (product) ->
+  p = product.masterData.staged
+  # set product type to staged subset
+  p.productType = product.productType
+  # set id for matching and version for update
+  p.id = product.id
+  p.version = product.version
+  p
+
 
 describe "Integration test", ->
 

            expect(b.taxCategory.id).toBe taxCategory2.id

    # deletion
            @newProduct.taxCategory = null
            @oldProduct.version = b.version

            data = @sync.buildActions @newProduct, @oldProduct
            data.update (e, r, b) ->

      expect(true).toBe false
      done()

  it 'should add, change and remove image', (done) ->
    @newProduct.masterVariant.images = [
      { url: '//example.com/image.png', dimensions: { h: 0, w: 0 } }
    ]

    # addition
    data = @sync.buildActions @newProduct, @oldProduct
    data.update (e, r, b) =>
      expect(r.statusCode).toBe 200
      expect(_.size b.masterData.staged.masterVariant.images).toBe 1
      expect(b.masterData.staged.masterVariant.images[0].url).toBe '//example.com/image.png'

    # change
      @oldProduct = getProductFromStaged b
      @newProduct.masterVariant.images = [
        { url: '//example.com/CHANGED.png', dimensions: { h: 0, w: 0 } }
      ]
      data = @sync.buildActions @newProduct, @oldProduct
      data.update (e, r, b) =>
        expect(r.statusCode).toBe 200
        expect(_.size b.masterData.staged.masterVariant.images).toBe 1
        expect(b.masterData.staged.masterVariant.images[0].url).toBe '//example.com/CHANGED.png'

    # deletion
        @oldProduct = getProductFromStaged b
        @newProduct.masterVariant.images = []
        data = @sync.buildActions @newProduct, @oldProduct
        data.update (e, r, b) ->
          expect(r.statusCode).toBe 200
          expect(_.size b.masterData.staged.masterVariant.images).toBe 0
          done()

describe "Integration test between projects", ->

