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

    variants: []
  }
]

describe 'ProductImport', ->


      newProduct = sampleProducts[0]
      expect(@import._isExistingEntry(existingProduct,sampleProductProjectionResponse)).toBeDefined()
      expect(@import._isExistingEntry(existingProduct,sampleProductProjectionResponse).masterVariant.sku).toEqual "e"
      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)


