forked from labd/commercetools-node-mock
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix/allow creating customers with storekey reference (labd#254)
This fixes a bug with setting the stores of a customer, it previously would throw an error if a single store was set using a storekey.
- Loading branch information
Showing
3 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@labdigital/commercetools-mock": patch | ||
--- | ||
|
||
Fix setting stores to customer by storekey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ describe("Customer repository", () => { | |
); | ||
}); | ||
|
||
test("adding stores to customer", async () => { | ||
test("adding multiple stores to customer", async () => { | ||
const store1: Store = { | ||
id: "d0016081-e9af-48a7-8133-1f04f340a335", | ||
key: "store-1", | ||
|
@@ -112,6 +112,46 @@ describe("Customer repository", () => { | |
]); | ||
}); | ||
|
||
test("adding single store to customer", async () => { | ||
const store1: Store = { | ||
id: "58082253-fe4e-4714-941f-86ab596d42ed", | ||
key: "store-1", | ||
name: { | ||
en: "Store 1", | ||
}, | ||
version: 1, | ||
createdAt: "2021-09-02T12:23:30.036Z", | ||
lastModifiedAt: "2021-09-02T12:23:30.546Z", | ||
languages: [], | ||
distributionChannels: [], | ||
countries: [], | ||
supplyChannels: [], | ||
productSelections: [], | ||
}; | ||
|
||
storage.add("dummy", "store", store1); | ||
|
||
const result = repository.create( | ||
{ projectKey: "dummy" }, | ||
{ | ||
email: "[email protected]", | ||
stores: [ | ||
{ | ||
typeId: "store", | ||
key: store1.key, | ||
}, | ||
], | ||
}, | ||
); | ||
|
||
expect(result?.stores).toEqual([ | ||
{ | ||
typeId: "store", | ||
key: store1.key, | ||
}, | ||
]); | ||
}); | ||
|
||
test("adding customer without linked stores", async () => { | ||
const result = repository.create( | ||
{ projectKey: "dummy" }, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters