       newProduct = sampleProducts[0]
       expect(@import._isExistingEntry(existingProduct,sampleProductProjectionResponse)).toBeDefined()
       expect(@import._isExistingEntry(existingProduct,sampleProductProjectionResponse).masterVariant.sku).toEqual "e"
-      expect(@import._isExistingEntry(newProduct,sampleProductProjectionResponse)).toBeUndefined()+      expect(@import._isExistingEntry(newProduct,sampleProductProjectionResponse)).toBeUndefined()
+
+  describe '::_resolveReference', ->
+
+    it 'should resolve product type reference and cache the result', (done) ->
+      @import._resetCache()
+      spyOn(@import.client.productTypes, "fetch").and.callFake => Promise.resolve(sampleProductTypeResponse)
+      productTypeRef = { id: 'AGS'}
+      @import._resolveReference(@import.client.productTypes, 'productType', productTypeRef, "name=\"#{productTypeRef.id}\"")
+        .then (result) =>
+          console.log("Entered")
+          expect(result).toEqual sampleProductTypeResponse.body.results[0]
+          console.log("Cached result: ")
+          console.log(@import._cache.productType[productTypeRef.id])
+          console.log(sampleProductTypeResponse.body.results[0])
+          expect(@import._cache.productType["AGS"]).toEqual sampleProductTypeResponse.body.results[0]
+          done()
+          .catch (err) -> done(err)
+
+

_ = require 'underscore'
_.mixin require('underscore-mixins')
{ProductImport} = require '../lib'
Config = require('../config')
Promise = require 'bluebird'
fs = require 'fs'


    variants: []
  }
]

sampleProductTypeResponse =
  body:
    results: [
      {
        "id": "product_type_internal_id",
        "version": 1,
        "name": "AGS",
        "description": "Gütesiegel",
        "classifier": "Complex",
        "attributes": [ ],
        "createdAt": "2015-04-15T15:11:07.175Z",
        "lastModifiedAt": "2015-04-15T15:11:07.175Z"
      }
    ]

describe 'ProductImport', ->

