diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-22 12:33:57 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-22 12:33:57 -0500 |
| commit | 0b330d8d365f8cba80d0ead6f59f66cc6ee1ffcd (patch) | |
| tree | 66c396e96f696657c04d377e5b4492091b53eb81 /test | |
| parent | acb2ba68247ca6272513d6a27ec3f13f49558cb4 (diff) | |
test logged-out cart flow
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 |
