diff --git a/src/customer-import.js b/src/customer-import.js index f5452cd..37e9043 100644 --- a/src/customer-import.js +++ b/src/customer-import.js @@ -114,7 +114,7 @@ export default class CustomerImport { return Promise.resolve(customerGroupId) } return this.insertCustomerGroup(customerGroupName) - .then(({ body: customerGroup }) => { + .then(customerGroup => { return customerGroup.id }) } @@ -128,6 +128,10 @@ export default class CustomerImport { insertCustomerGroup (customerGroupName) { return this.client.customerGroups.create({ groupName: customerGroupName }) + .then(({ body: newCustomerGroup }) => { + this.customerGroups[customerGroupName] = newCustomerGroup.id + return newCustomerGroup + }) } validateCustomer (customer) { diff --git a/tests/integration/customer-import.js b/tests/integration/customer-import.js index d0b9bdc..46a900c 100644 --- a/tests/integration/customer-import.js +++ b/tests/integration/customer-import.js @@ -193,9 +193,9 @@ describe('customer import module', function () { email: 'philipp.sporrer@commercetools.de', customerGroup: 'commercetools' } - customerImport.insertCustomerGroup('commercetools') + customerImport.loadCustomerGroups() .then(() => { - customerImport.loadCustomerGroups() + customerImport.insertCustomerGroup('commercetools') .then(() => { customerImport.importCustomer(customer) .then((customerWithGroupReference) => {