diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/test/05-cart-flows.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/test/05-cart-flows.js b/test/test/05-cart-flows.js new file mode 100644 index 00000000..c5173f3d --- /dev/null +++ b/test/test/05-cart-flows.js @@ -0,0 +1,49 @@ +var sdk = require('../lib/sdk') +var promise = require('../lib/promise') +var assert = require("assert") + +describe('cart_flows', function(){ + + describe('#can_add_products_to_an_empty_cart()', function(){ + it('initializes the cart', function(done){ + promise(sdk.cart.initialize, { data: {} }).then(function(data){ + assert(data.Header.StatusCode == 200) + assert(sdk.cart.id !== "") + assert(sdk.cart.token !== "") + done() + }) + }) + + it('adds item to cart', function(done){ + var product_item = { + "Code10": "37725683OV", + "Size": 4, + } + promise(sdk.cart.add_item, { data: product_item }).then(function(data){ + assert(data.Header.StatusCode == 201) + done() + }) + }) + + it('has added product to cart', function(done){ + promise(sdk.cart.get_status, {}).then(function(data){ + assert(data.Header.StatusCode == 200) + assert(data.Cart.Items.length == 1) + console.log(JSON.stringify(data, null, 2)) + done() + }) + }) + + it('removes item from cart', function(done){ + var product_item = { + "Code10": "37725683OV", + "Size": 4, + } + promise(sdk.cart.delete_item, { data: product_item }).then(function(data){ + // console.log(data) + assert(data.Header.StatusCode == 200) + done() + }) + }) + }) +})
\ No newline at end of file |
