-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Ecwid/checkout-info-storage
get cart info from checkout info storage instead of legacy cart record
- Loading branch information
Showing
6 changed files
with
70 additions
and
1 deletion.
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
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,12 @@ | ||
import { LocalStorageCheckout } from '../type/local-storage'; | ||
import { Cart } from '../type/cart'; | ||
|
||
export default class CheckoutConverter { | ||
toCart(localStorageCart: LocalStorageCheckout): Cart { | ||
return { | ||
cartId: '', | ||
items: [], | ||
productsQuantity: localStorageCart.itemsCount, | ||
}; | ||
} | ||
} |
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
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
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,17 @@ | ||
import CheckoutConverter from '../../src/converter/checkout-converter'; | ||
import { LocalStorageCheckout } from '../../src/type/local-storage'; | ||
|
||
test('LocalStorageCheckout to Cart conversion', () => { | ||
const cartConverter = new CheckoutConverter(); | ||
const localStorageCheckout: LocalStorageCheckout = { | ||
id: 'GkpzhWnTX2gBvgBQ', | ||
itemsCount: 4, | ||
}; | ||
const expectedResult = { | ||
cartId: '', | ||
items: [], | ||
productsQuantity: 4, | ||
}; | ||
const actualResult = cartConverter.toCart(localStorageCheckout); | ||
expect(actualResult).toEqual(expectedResult); | ||
}); |
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