summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-03-04 22:37:20 +0100
committerJules Laplace <jules@okfoc.us>2016-03-04 22:37:20 +0100
commit08c203b4dc4b9fdacd9aa0f2f2074dbd7d431a80 (patch)
tree40719f082ec67774654d10f50a332ea06ba23bb8 /test
parent3a7ab01806ec52c048284029613b9bdaa0f6ec25 (diff)
checkin stuff
Diffstat (limited to 'test')
-rwxr-xr-xtest/test/02-login.js8
-rw-r--r--test/test/06-more-cart-flows.js112
2 files changed, 120 insertions, 0 deletions
diff --git a/test/test/02-login.js b/test/test/02-login.js
index e0484dbb..cd5869d7 100755
--- a/test/test/02-login.js
+++ b/test/test/02-login.js
@@ -75,6 +75,14 @@ describe('account', function(){
})
})
+ it('does not fetch anything if the tokens are invalid', function(done){
+ promise(sdk.account.checkin, {}).then(function(data){
+ console.log("SHOULD NOT WORK BUT IT DID??", data)
+ }).error(function(data){
+ done()
+ })
+ })
+
it('works if no token is set on auth', function(done){
sdk.auth.access_token = ""
sdk.auth.user_id = -1
diff --git a/test/test/06-more-cart-flows.js b/test/test/06-more-cart-flows.js
new file mode 100644
index 00000000..892c9e47
--- /dev/null
+++ b/test/test/06-more-cart-flows.js
@@ -0,0 +1,112 @@
+var sdk = require('../lib/sdk')
+var promise = require('../lib/promise')
+var assert = require("assert")
+
+// sdk.cart.initialize
+// sdk.cart.set_user
+// sdk.cart.add_item
+// sdk.cart.delete_item
+// sdk.cart.get_status
+
+describe('buggy_cart', function(){
+ var new_user_data = {
+ "Email": "blahtest+" + Math.floor(Math.random() * 10000000) + "@blahtest.com",
+ "Password": "TestPasswordYOOX",
+ "Gender": "U",
+ "Name": "test",
+ "Surname": "test",
+ "DataProfiling": true,
+ }
+ var test_product = {
+ "Code10": "37725683OV",
+ "Size": 4,
+ }
+
+ this.timeout(30000)
+
+ var test_item
+
+ describe('#signup()', function(){
+ it('makes a user and creates a token', function(done){
+ promise(sdk.account.signup, { data: new_user_data }).then(function(data){
+ // console.log(data)
+ assert(data.Header.StatusCode == 201)
+ assert('UserAccount' in data)
+
+ // console.log(data)
+
+ done()
+ })
+ })
+ })
+
+ describe('#initialize()', 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()
+ })
+ })
+ })
+
+ describe('#set_user()', function(){
+ it('sets user to cart', function(done){
+ var user_creds = {
+ "UserId": sdk.auth.user_id,
+ "UserToken": sdk.auth.access_token,
+ }
+ promise(sdk.cart.set_user, { data: user_creds }).then(function(data){
+ assert(data.Header.StatusCode == 200)
+ done()
+ })
+ })
+ })
+
+ describe('#collection()', function(){
+ it('returns a collection', function(done){
+ promise(sdk.product.collection).then(function(data){
+ assert(data.Header.StatusCode == 200)
+ assert(data.SearchResponseFull.Results.Items.length > 0)
+ test_item = data.SearchResponseFull.Results.Items[0]
+ done()
+ }).error(function(error){
+ done()
+ })
+ })
+ })
+
+ describe('#add_item()', function(){
+ it('adds item to cart', function(done){
+ var product_item = {
+ Code10: test_item.DefaultCode10,
+ Size: test_item.Sizes[0].Id,
+ }
+ promise(sdk.cart.add_item, { data: product_item }).then(function(data){
+ assert(data.Header.StatusCode == 201)
+ done()
+ }).error(function(){
+ console.log("ERROR ADDING TO CART")
+ done()
+ })
+ })
+
+ it('does not add item if cart is messed up', function(done){
+ var product_item = {
+ Code10: test_item.DefaultCode10,
+ Size: test_item.Sizes[0].Id,
+ }
+ sdk.cart.id = "BROKEN"
+ sdk.cart.token = "BROKEN"
+ promise(sdk.cart.add_item, { data: product_item }).then(function(data){
+ assert(data.Header.StatusCode !== 201)
+ }).error(function(data){
+ assert(data.status !== 201)
+ done()
+ })
+ })
+
+ })
+
+})