Skip to content
Browse files

updating tests with more logging and consistent, cleaner works

  • Loading branch information...
1 parent c68460f commit 29316b9b7cdce3d9a6665be5c75bd497df31104c @mckelvey committed
View
37 test/helpers.coffee
@@ -1,16 +1,25 @@
-module.exports = (title = '', Instagram, type, method, params = {}, assertions) ->
- indent = " "
- params['complete'] = (data, pagination) ->
- console.log "\n#{title}\n#{indent}connection/parsing succeeded"
- try
- assertions data, pagination
- console.log "#{indent}data met assertions"
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
+indent = " "
+
+module.exports =
+ indent: indent
+ helper: (title = '', Instagram, type, method, params = {}, assertions) ->
+ params['complete'] = (data, pagination) ->
+ console.log "\n#{title}\n#{indent}connection/parsing succeeded"
+ try
+ assertions data, pagination
+ console.log "#{indent}data met assertions"
+ catch e
+ console.log "#{indent}data failed to meet the assertion(s): #{e}"
+ throw e
+ params['error'] = (e, data, caller) ->
+ console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
throw e
- params['error'] = (e, data, caller) ->
- console.log "\n#{title}\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- Instagram[type][method] params
+ Instagram[type][method] params
+ output: (message, value = null) ->
+ console.log "#{indent}#{message}"
+ if value?
+ if typeof value is 'object'
+ console.log "#{indent}#{indent}it was: " + JSON.stringify(value)
+ else
+ console.log "#{indent}#{indent}it was: #{value}"
View
61 test/helpers.js
@@ -1,28 +1,43 @@
(function() {
- module.exports = function(title, Instagram, type, method, params, assertions) {
- var indent;
- if (title == null) {
- title = '';
- }
- if (params == null) {
- params = {};
- }
- indent = " ";
- params['complete'] = function(data, pagination) {
- console.log("\n" + title + "\n" + indent + "connection/parsing succeeded");
- try {
- assertions(data, pagination);
- return console.log("" + indent + "data met assertions");
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
+ var indent;
+ indent = " ";
+ module.exports = {
+ indent: indent,
+ helper: function(title, Instagram, type, method, params, assertions) {
+ if (title == null) {
+ title = '';
+ }
+ if (params == null) {
+ params = {};
+ }
+ params['complete'] = function(data, pagination) {
+ console.log("\n" + title + "\n" + indent + "connection/parsing succeeded");
+ try {
+ assertions(data, pagination);
+ return console.log("" + indent + "data met assertions");
+ } catch (e) {
+ console.log("" + indent + "data failed to meet the assertion(s): " + e);
+ throw e;
+ }
+ };
+ params['error'] = function(e, data, caller) {
+ console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
throw e;
+ };
+ return Instagram[type][method](params);
+ },
+ output: function(message, value) {
+ if (value == null) {
+ value = null;
+ }
+ console.log("" + indent + message);
+ if (value != null) {
+ if (typeof value === 'object') {
+ return console.log(("" + indent + indent + "it was: ") + JSON.stringify(value));
+ } else {
+ return console.log("" + indent + indent + "it was: " + value);
+ }
}
- };
- params['error'] = function(e, data, caller) {
- console.log("\n" + title + "\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- };
- return Instagram[type][method](params);
+ }
};
}).call(this);
View
18 test/instagram.locations.coffee
@@ -8,22 +8,32 @@ console.log "\nInstagram API Node.js Lib Tests :: Locations"
Instagram = require '../lib/class.instagram'
assert = require 'assert'
should = require 'should'
-test_helper = require './helpers.js'
+test = require './helpers.js'
module.exports =
'locations#info for id#1': ->
- test_helper 'locations#info for id#1', Instagram, 'locations', 'info', { location_id: 1 }, (data) ->
+ test.helper 'locations#info for id#1', Instagram, 'locations', 'info', { location_id: 1 }, (data) ->
data.should.have.property 'name', 'Dogpatch Labs'
+ test.output "data had the property 'name' equal to 'Dogpatch Labs'"
data.latitude.should.be.above 0
+ test.output "data had the property 'latitude' greater than zero", data.latitude
data.longitude.should.be.below 0
+ test.output "data had the property 'longitude' less than zero", data.longitude
'locations#recent for id#1': ->
- test_helper 'locations#recent for id#1', Instagram, 'locations', 'recent', { location_id: 1 }, (data, pagination) ->
+ test.helper 'locations#recent for id#1', Instagram, 'locations', 'recent', { location_id: 1 }, (data, pagination) ->
data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
data[0].should.have.property 'id'
+ test.output "data[0] had the property 'id'", data[0].id
pagination.should.have.property 'next_url'
+ test.output "pagination had the property 'next_url'", pagination.next_url
pagination.should.have.property 'next_max_id' or pagination.should.have.property 'next_min_id'
+ test.output "pagination had the property 'next_max_id' or 'next_min_id'", pagination
'locations#search for 48.858844300000001/2.2943506': ->
- test_helper 'locations#search for 48.858844300000001/2.2943506', Instagram, 'locations', 'search', { lat: 48.858844300000001, lng: 2.2943506 }, (data) ->
+ test.helper 'locations#search for 48.858844300000001/2.2943506', Instagram, 'locations', 'search', { lat: 48.858844300000001, lng: 2.2943506 }, (data) ->
data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
data[0].should.have.property 'id'
+ test.output "data[0] had the property 'id'", data[0].id
data[0].should.have.property 'name'
+ test.output "data[0] had the property 'name'", data[0].name
View
26 test/instagram.locations.js
@@ -1,40 +1,50 @@
(function() {
/*
Testing Location Methods
- */ var Instagram, assert, should, test_helper;
+ */ var Instagram, assert, should, test;
console.log("\nInstagram API Node.js Lib Tests :: Locations");
Instagram = require('../lib/class.instagram');
assert = require('assert');
should = require('should');
- test_helper = require('./helpers.js');
+ test = require('./helpers.js');
module.exports = {
'locations#info for id#1': function() {
- return test_helper('locations#info for id#1', Instagram, 'locations', 'info', {
+ return test.helper('locations#info for id#1', Instagram, 'locations', 'info', {
location_id: 1
}, function(data) {
data.should.have.property('name', 'Dogpatch Labs');
+ test.output("data had the property 'name' equal to 'Dogpatch Labs'");
data.latitude.should.be.above(0);
- return data.longitude.should.be.below(0);
+ test.output("data had the property 'latitude' greater than zero", data.latitude);
+ data.longitude.should.be.below(0);
+ return test.output("data had the property 'longitude' less than zero", data.longitude);
});
},
'locations#recent for id#1': function() {
- return test_helper('locations#recent for id#1', Instagram, 'locations', 'recent', {
+ return test.helper('locations#recent for id#1', Instagram, 'locations', 'recent', {
location_id: 1
}, function(data, pagination) {
data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
data[0].should.have.property('id');
+ test.output("data[0] had the property 'id'", data[0].id);
pagination.should.have.property('next_url');
- return pagination.should.have.property('next_max_id' || pagination.should.have.property('next_min_id'));
+ test.output("pagination had the property 'next_url'", pagination.next_url);
+ pagination.should.have.property('next_max_id' || pagination.should.have.property('next_min_id'));
+ return test.output("pagination had the property 'next_max_id' or 'next_min_id'", pagination);
});
},
'locations#search for 48.858844300000001/2.2943506': function() {
- return test_helper('locations#search for 48.858844300000001/2.2943506', Instagram, 'locations', 'search', {
+ return test.helper('locations#search for 48.858844300000001/2.2943506', Instagram, 'locations', 'search', {
lat: 48.858844300000001,
lng: 2.2943506
}, function(data) {
data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
data[0].should.have.property('id');
- return data[0].should.have.property('name');
+ test.output("data[0] had the property 'id'", data[0].id);
+ data[0].should.have.property('name');
+ return test.output("data[0] had the property 'name'", data[0].name);
});
}
};
View
42 test/instagram.media.coffee
@@ -8,40 +8,52 @@ console.log "\nInstagram API Node.js Lib Tests :: Media"
Instagram = require '../lib/class.instagram'
assert = require 'assert'
should = require 'should'
-test_helper = require './helpers.js'
+test = require './helpers.js'
module.exports =
'media#popular': ->
- test_helper 'media#popular', Instagram, 'media', 'popular', {}, (data) ->
+ test.helper 'media#popular', Instagram, 'media', 'popular', {}, (data) ->
data.length.should.equal 32
+ test.output "data had length equal to 32"
data[0].should.have.property 'id'
+ test.output "data[0] had the property 'id'", data[0].id
'media#info for id#3': ->
- test_helper 'media#info for id#3', Instagram, 'media', 'info', { media_id: 3 }, (data) ->
+ test.helper 'media#info for id#3', Instagram, 'media', 'info', { media_id: 3 }, (data) ->
data.should.have.property 'id', '3'
+ test.output "data had the property 'id' equal to 3"
data.should.have.property 'created_time', '1279315783'
+ test.output "data had the property 'created_time' equal to 1279315783"
'media#search for 48.858844300000001/2.2943506': ->
- test_helper 'media#search for 48.858844300000001/2.2943506', Instagram, 'media', 'search', { lat: 48.858844300000001, lng: 2.2943506 }, (data) ->
+ test.helper 'media#search for 48.858844300000001/2.2943506', Instagram, 'media', 'search', { lat: 48.858844300000001, lng: 2.2943506 }, (data) ->
data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
data[0].should.have.property 'id'
+ test.output "data[0] had the property 'id'", data[0].id
'media#like id#3': ->
- test_helper 'media#like id#3', Instagram, 'media', 'like', { media_id: 3 }, (data) ->
+ test.helper 'media#like id#3', Instagram, 'media', 'like', { media_id: 3 }, (data) ->
throw "like failed" if data isnt null
- console.log " liked media #3"
- test_helper 'media#likes for id#3', Instagram, 'media', 'likes', { media_id: 3 }, (data) ->
+ test.output "data was null; we liked media #3"
+ test.helper 'media#likes for id#3', Instagram, 'media', 'likes', { media_id: 3 }, (data) ->
data.length.should.be.above 0
- test_helper 'media#unlike id#3', Instagram, 'media', 'unlike', { media_id: 3 }, (data) ->
+ test.output "data had length greater than 0", data.length
+ test.helper 'media#unlike id#3', Instagram, 'media', 'unlike', { media_id: 3 }, (data) ->
throw "unlike failed" if data isnt null
- console.log " unliked media #3"
+ test.output "data was null; we unliked media #3"
'media#comment id#53355234': ->
- test_helper 'media#comment id#53355234', Instagram, 'media', 'comment', { media_id: 53355234, text: 'Instagame was here.' }, (data) ->
+ test.helper 'media#comment id#53355234', Instagram, 'media', 'comment', { media_id: 53355234, text: 'Instagame was here.' }, (data) ->
data.should.have.property 'id'
+ test.output "data had the property 'id'", data.id
data.should.have.property 'from'
+ test.output "data had the property 'from'", data.from
data.should.have.property 'created_time'
+ test.output "data had the property 'created_time'", data.created_time
data.should.have.property 'text'
+ test.output "data had the property 'text'", data.text
comment_id = data['id']
- console.log " created comment #{comment_id}"
- test_helper 'media#comments for id#53355234', Instagram, 'media', 'comments', { media_id: 53355234 }, (data) ->
+ test.output "created comment #{comment_id}"
+ test.helper 'media#comments for id#53355234', Instagram, 'media', 'comments', { media_id: 53355234 }, (data) ->
data.length.should.be.above 0
- test_helper 'media#uncomment id#53355234', Instagram, 'media', 'uncomment', { media_id: 53355234, comment_id: comment_id }, (data) ->
- throw "unlike failed" if data isnt null
- console.log " deleted comment #{comment_id}"
+ test.output "data had length greater than 0", data.length
+ test.helper 'media#uncomment id#53355234', Instagram, 'media', 'uncomment', { media_id: 53355234, comment_id: comment_id }, (data) ->
+ throw "uncomment failed" if data isnt null
+ test.output "data was null; we deleted comment #{comment_id}"
View
50 test/instagram.media.js
@@ -1,83 +1,95 @@
(function() {
/*
Testing Media Methods
- */ var Instagram, assert, should, test_helper;
+ */ var Instagram, assert, should, test;
console.log("\nInstagram API Node.js Lib Tests :: Media");
Instagram = require('../lib/class.instagram');
assert = require('assert');
should = require('should');
- test_helper = require('./helpers.js');
+ test = require('./helpers.js');
module.exports = {
'media#popular': function() {
- return test_helper('media#popular', Instagram, 'media', 'popular', {}, function(data) {
+ return test.helper('media#popular', Instagram, 'media', 'popular', {}, function(data) {
data.length.should.equal(32);
- return data[0].should.have.property('id');
+ test.output("data had length equal to 32");
+ data[0].should.have.property('id');
+ return test.output("data[0] had the property 'id'", data[0].id);
});
},
'media#info for id#3': function() {
- return test_helper('media#info for id#3', Instagram, 'media', 'info', {
+ return test.helper('media#info for id#3', Instagram, 'media', 'info', {
media_id: 3
}, function(data) {
data.should.have.property('id', '3');
- return data.should.have.property('created_time', '1279315783');
+ test.output("data had the property 'id' equal to 3");
+ data.should.have.property('created_time', '1279315783');
+ return test.output("data had the property 'created_time' equal to 1279315783");
});
},
'media#search for 48.858844300000001/2.2943506': function() {
- return test_helper('media#search for 48.858844300000001/2.2943506', Instagram, 'media', 'search', {
+ return test.helper('media#search for 48.858844300000001/2.2943506', Instagram, 'media', 'search', {
lat: 48.858844300000001,
lng: 2.2943506
}, function(data) {
data.length.should.be.above(0);
- return data[0].should.have.property('id');
+ test.output("data had length greater than 0", data.length);
+ data[0].should.have.property('id');
+ return test.output("data[0] had the property 'id'", data[0].id);
});
},
'media#like id#3': function() {
- return test_helper('media#like id#3', Instagram, 'media', 'like', {
+ return test.helper('media#like id#3', Instagram, 'media', 'like', {
media_id: 3
}, function(data) {
if (data !== null) {
throw "like failed";
}
- console.log(" liked media #3");
- return test_helper('media#likes for id#3', Instagram, 'media', 'likes', {
+ test.output("data was null; we liked media #3");
+ return test.helper('media#likes for id#3', Instagram, 'media', 'likes', {
media_id: 3
}, function(data) {
data.length.should.be.above(0);
- return test_helper('media#unlike id#3', Instagram, 'media', 'unlike', {
+ test.output("data had length greater than 0", data.length);
+ return test.helper('media#unlike id#3', Instagram, 'media', 'unlike', {
media_id: 3
}, function(data) {
if (data !== null) {
throw "unlike failed";
}
- return console.log(" unliked media #3");
+ return test.output("data was null; we unliked media #3");
});
});
});
},
'media#comment id#53355234': function() {
- return test_helper('media#comment id#53355234', Instagram, 'media', 'comment', {
+ return test.helper('media#comment id#53355234', Instagram, 'media', 'comment', {
media_id: 53355234,
text: 'Instagame was here.'
}, function(data) {
var comment_id;
data.should.have.property('id');
+ test.output("data had the property 'id'", data.id);
data.should.have.property('from');
+ test.output("data had the property 'from'", data.from);
data.should.have.property('created_time');
+ test.output("data had the property 'created_time'", data.created_time);
data.should.have.property('text');
+ test.output("data had the property 'text'", data.text);
comment_id = data['id'];
- console.log(" created comment " + comment_id);
- return test_helper('media#comments for id#53355234', Instagram, 'media', 'comments', {
+ test.output("created comment " + comment_id);
+ return test.helper('media#comments for id#53355234', Instagram, 'media', 'comments', {
media_id: 53355234
}, function(data) {
data.length.should.be.above(0);
- return test_helper('media#uncomment id#53355234', Instagram, 'media', 'uncomment', {
+ test.output("data had length greater than 0", data.length);
+ return test.helper('media#uncomment id#53355234', Instagram, 'media', 'uncomment', {
media_id: 53355234,
comment_id: comment_id
}, function(data) {
if (data !== null) {
- throw "unlike failed";
+ throw "uncomment failed";
}
- return console.log(" deleted comment " + comment_id);
+ return test.output("data was null; we deleted comment " + comment_id);
});
});
});
View
328 test/instagram.subscriptions.coffee
@@ -43,6 +43,7 @@ Tests
assert = require 'assert'
should = require 'should'
+test = require './helpers.js'
completed = 0
to_do = 0
@@ -50,243 +51,106 @@ indent = " "
module.exports =
'tags#subscriptions': ->
- title = "tags#subscriptions"
- unsubscribe = (subscription_id) ->
- Instagram.tags.unsubscribe {
- id: subscription_id
- complete: (data) ->
- console.log "\n#{title} unsubscribe from #{subscription_id}\n#{indent}connection/parsing succeeded"
- try
- assert.isNull data
- console.log "#{indent}data met assertions"
- completed += 1
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} unsubscribe\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- list = (subscription_id) ->
- Instagram.subscriptions.list {
- complete: (data) ->
- console.log "\n#{title} list\n#{indent}connection/parsing succeeded"
- try
- data.should.not.be.empty
- console.log "#{indent}data met assertions"
- unsubscribe subscription_id
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} list\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- Instagram.tags.subscribe {
- object_id: 'blue'
- callback_url: CALLBACK_URL
- complete: (data) ->
- console.log "\n#{title} subscribe#blue\n#{indent}connection/parsing succeeded"
- try
- data.should.have.property 'id'
- data.id.should.be.above 0
- data.should.have.property 'type', 'subscription'
- console.log "#{indent}data met assertions"
- list data['id']
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} subscribe#blue\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
+ test.helper "tags#subscriptions subscribe to 'blue'", Instagram, 'tags', 'subscribe', { object_id: 'blue' }, (data) ->
+ data.should.have.property 'id'
+ test.output "data had the property 'id'"
+ data.id.should.be.above 0
+ test.output "data.id was greater than 0", data.id
+ data.should.have.property 'type', 'subscription'
+ test.output "data had the property 'type' equal to 'subscription'", data
+ subscription_id = data.id
+ test.helper 'tags#subscriptions list', Instagram, 'subscriptions', 'list', {}, (data) ->
+ data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
+ found = false
+ for i of data
+ found = true if data[i].id is subscription_id
+ throw "subscription not found" if !found
+ test.output "data had the subscription #{subscription_id}"
+ test.helper "tags#subscriptions unsubscribe from 'blue'", Instagram, 'tags', 'unsubscribe', { id: subscription_id }, (data) ->
+ throw "tag 'blue' unsubscribe failed" if data isnt null
+ test.output "data was null; we unsubscribed from the subscription #{subscription_id}"
'locations#subscriptions': ->
- title = "locations#subscriptions"
- unsubscribe = (subscription_id) ->
- Instagram.locations.unsubscribe {
- id: subscription_id
- complete: (data) ->
- console.log "\n#{title} unsubscribe from #{subscription_id}\n#{indent}connection/parsing succeeded"
- try
- assert.isNull data
- console.log "#{indent}data met assertions"
- completed += 1
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} unsubscribe\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- list = (subscription_id) ->
- Instagram.subscriptions.list {
- complete: (data) ->
- console.log "\n#{title} list\n#{indent}connection/parsing succeeded"
- try
- data.should.not.be.empty
- console.log "#{indent}data met assertions"
- unsubscribe subscription_id
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} list\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- Instagram.locations.subscribe {
- object_id: '1257285'
- callback_url: CALLBACK_URL
- complete: (data) ->
- console.log "\n#{title} subscribe#1257285\n#{indent}connection/parsing succeeded"
- try
- data.should.have.property 'id'
- data.id.should.be.above 0
- data.should.have.property 'type', 'subscription'
- console.log "#{indent}data met assertions"
- list data['id']
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} subscribe#1257285\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
+ test.helper "locations#subscriptions subscribe to location '1257285'", Instagram, 'locations', 'subscribe', { object_id: '1257285' }, (data) ->
+ data.should.have.property 'id'
+ test.output "data had the property 'id'"
+ data.id.should.be.above 0
+ test.output "data.id was greater than 0", data.id
+ data.should.have.property 'type', 'subscription'
+ test.output "data had the property 'type' equal to 'subscription'", data
+ subscription_id = data.id
+ test.helper 'locations#subscriptions list', Instagram, 'subscriptions', 'list', {}, (data) ->
+ data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
+ found = false
+ for i of data
+ found = true if data[i].id is subscription_id
+ throw "subscription not found" if !found
+ test.output "data had the subscription #{subscription_id}"
+ test.helper "locations#subscriptions unsubscribe from location '1257285'", Instagram, 'locations', 'unsubscribe', { id: subscription_id }, (data) ->
+ throw "location '1257285' unsubscribe failed" if data isnt null
+ test.output "data was null; we unsubscribed from the subscription #{subscription_id}"
'media#subscriptions': ->
- title = "media#subscriptions"
- unsubscribe = (subscription_id) ->
- Instagram.media.unsubscribe {
- id: subscription_id
- complete: (data) ->
- console.log "\n#{title} unsubscribe from #{subscription_id}\n#{indent}connection/parsing succeeded"
- try
- assert.isNull data
- console.log "#{indent}data met assertions"
- completed += 1
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} unsubscribe\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- list = (subscription_id) ->
- Instagram.subscriptions.list {
- complete: (data) ->
- console.log "\n#{title} list\n#{indent}connection/parsing succeeded"
- try
- data.should.not.be.empty
- console.log "#{indent}data met assertions"
- unsubscribe subscription_id
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} list\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- Instagram.media.subscribe {
- lat: 48.858844300000001
- lng: 2.2943506
- radius: 1000
- callback_url: CALLBACK_URL
- complete: (data) ->
- console.log "\n#{title} subscribe#48.858844300000001/2.2943506\n#{indent}connection/parsing succeeded"
- try
+ test.helper "media#subscriptions subscribe to media near Eiffel Tower", Instagram, 'media', 'subscribe', { lat: 48.858844300000001, lng: 2.2943506, radius: 1000 }, (data) ->
+ data.should.have.property 'id'
+ test.output "data had the property 'id'"
+ data.id.should.be.above 0
+ test.output "data.id was greater than 0", data.id
+ data.should.have.property 'type', 'subscription'
+ test.output "data had the property 'type' equal to 'subscription'", data
+ subscription_id = data.id
+ test.helper 'media#subscriptions list', Instagram, 'subscriptions', 'list', {}, (data) ->
+ data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
+ found = false
+ for i of data
+ found = true if data[i].id is subscription_id
+ throw "subscription not found" if !found
+ test.output "data had the subscription #{subscription_id}"
+ test.helper "media#subscriptions unsubscribe from media near Eiffel Tower", Instagram, 'media', 'unsubscribe', { id: subscription_id }, (data) ->
+ throw "media near Eiffel Tower unsubscribe failed" if data isnt null
+ test.output "data was null; we unsubscribed from the subscription #{subscription_id}"
+ 'multi#subscriptions': ->
+ subscriptions = []
+ test.helper "subscriptions subscribe to tag 'red'", Instagram, 'subscriptions', 'subscribe', { object: 'tag', object_id: 'red' }, (data) ->
+ data.should.have.property 'id'
+ test.output "data had the property 'id'"
+ data.id.should.be.above 0
+ test.output "data.id was greater than 0", data.id
+ data.should.have.property 'type', 'subscription'
+ test.output "data had the property 'type' equal to 'subscription'", data
+ subscriptions[subscriptions.length] = data.id
+ test.helper "subscriptions subscribe to location '1257285'", Instagram, 'subscriptions', 'subscribe', { object: 'location', object_id: '1257285' }, (data) ->
+ data.should.have.property 'id'
+ test.output "data had the property 'id'"
+ data.id.should.be.above 0
+ test.output "data.id was greater than 0", data.id
+ data.should.have.property 'type', 'subscription'
+ test.output "data had the property 'type' equal to 'subscription'", data
+ subscriptions[subscriptions.length] = data.id
+ test.helper "subscriptions subscribe to media near Eiffel Tower", Instagram, 'subscriptions', 'subscribe', { object: 'geography', lat: 48.858844300000001, lng: 2.2943506, radius: 1000 }, (data) ->
data.should.have.property 'id'
+ test.output "data had the property 'id'"
data.id.should.be.above 0
+ test.output "data.id was greater than 0", data.id
data.should.have.property 'type', 'subscription'
- console.log "#{indent}data met assertions"
- list data['id']
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} subscribe#48.858844300000001/2.2943506\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- 'subscriptions': ->
- title = "subscriptions"
- unsubscribe = (ids) ->
- Instagram.subscriptions.unsubscribe_all {
- complete: (data) ->
- console.log "\n#{title} unsubscribe_all\n#{indent}connection/parsing succeeded"
- try
- assert.isNull data
- console.log "#{indent}data met assertions"
- completed += 1
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} unsubscribe_all\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- list = (ids) ->
- Instagram.subscriptions.list {
- complete: (data) ->
- console.log "\n#{title} list\n#{indent}connection/parsing succeeded"
- try
- data.length.should.equal 2
- console.log "#{indent}data met assertions"
- unsubscribe ids
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} list\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- subscribe_again = (ids) ->
- Instagram.subscriptions.subscribe {
- object: 'tag'
- object_id: 'green'
- complete: (data) ->
- console.log "\n#{title} subscribe#green\n#{indent}connection/parsing succeeded"
- try
- data.should.have.property 'id'
- data.id.should.be.above 0
- data.should.have.property 'type', 'subscription'
- console.log "#{indent}data met assertions"
- ids[ids.length] = data['id']
- list ids
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} subscribe#green\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
- Instagram.subscriptions.subscribe {
- object: 'tag'
- object_id: 'red'
- complete: (data) ->
- console.log "\n#{title} subscribe#red\n#{indent}connection/parsing succeeded"
- try
- data.should.have.property 'id'
- data.id.should.be.above 0
- data.should.have.property 'type', 'subscription'
- console.log "#{indent}data met assertions"
- subscribe_again [data['id']]
- catch e
- console.log "#{indent}data failed to meet the assertion(s): #{e}"
- throw e
- error: (e, data, caller) ->
- console.log "\n#{title} subscribe#red\n#{indent}connection/parsing failed"
- console.log "#{indent}error: #{e}\n#{indent}data: #{data}\n#{indent}caller: #{caller}"
- throw e
- }
+ test.output "data had the property 'type' equal to 'subscription'", data
+ subscriptions[subscriptions.length] = data.id
+ test.helper 'subscriptions list', Instagram, 'subscriptions', 'list', {}, (data) ->
+ data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
+ subscriptions_list = []
+ for i of data
+ subscriptions_list[subscriptions_list.length] = data[i].id
+ found = true
+ for i of subscriptions
+ found = false if subscriptions[i] not in subscriptions_list
+ throw "subscription not found" if !found
+ test.output "data had the subscription #{subscription_id}"
+ test.helper "subscriptions unsubscribe_all", Instagram, 'subscriptions', 'unsubscribe_all', {}, (data) ->
+ throw "unsubscribe_all failed" if data isnt null
+ test.output "data was null; we unsubscribed from the subscriptions #{subscriptions_list.join(', ')}"
+
###
App Termination
View
427 test/instagram.subscriptions.js
@@ -1,7 +1,13 @@
(function() {
/*
Setup Lib for Testing
- */ var CALLBACK_URL, HOST, Instagram, PATH, PORT, app, assert, callback, completed, express, i, indent, iterations, should, to_do, url, waiting;
+ */ var CALLBACK_URL, HOST, Instagram, PATH, PORT, app, assert, callback, completed, express, i, indent, iterations, should, test, to_do, url, waiting;
+ var __indexOf = Array.prototype.indexOf || function(item) {
+ for (var i = 0, l = this.length; i < l; i++) {
+ if (this[i] === item) return i;
+ }
+ return -1;
+ };
Instagram = require('../lib/class.instagram');
/*
Setup Temp App for Subscription Testing
@@ -37,302 +43,189 @@
*/
assert = require('assert');
should = require('should');
+ test = require('./helpers.js');
completed = 0;
to_do = 0;
indent = " ";
module.exports = {
'tags#subscriptions': function() {
- var list, title, unsubscribe;
- title = "tags#subscriptions";
- unsubscribe = function(subscription_id) {
- return Instagram.tags.unsubscribe({
- id: subscription_id,
- complete: function(data) {
- console.log("\n" + title + " unsubscribe from " + subscription_id + "\n" + indent + "connection/parsing succeeded");
- try {
- assert.isNull(data);
- console.log("" + indent + "data met assertions");
- return completed += 1;
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
+ return test.helper("tags#subscriptions subscribe to 'blue'", Instagram, 'tags', 'subscribe', {
+ object_id: 'blue'
+ }, function(data) {
+ var subscription_id;
+ data.should.have.property('id');
+ test.output("data had the property 'id'");
+ data.id.should.be.above(0);
+ test.output("data.id was greater than 0", data.id);
+ data.should.have.property('type', 'subscription');
+ test.output("data had the property 'type' equal to 'subscription'", data);
+ subscription_id = data.id;
+ return test.helper('tags#subscriptions list', Instagram, 'subscriptions', 'list', {}, function(data) {
+ var found, i;
+ data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
+ found = false;
+ for (i in data) {
+ if (data[i].id === subscription_id) {
+ found = true;
}
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " unsubscribe\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
}
- });
- };
- list = function(subscription_id) {
- return Instagram.subscriptions.list({
- complete: function(data) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing succeeded");
- try {
- data.should.not.be.empty;
- console.log("" + indent + "data met assertions");
- return unsubscribe(subscription_id);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
+ if (!found) {
+ throw "subscription not found";
}
+ test.output("data had the subscription " + subscription_id);
+ return test.helper("tags#subscriptions unsubscribe from 'blue'", Instagram, 'tags', 'unsubscribe', {
+ id: subscription_id
+ }, function(data) {
+ if (data !== null) {
+ throw "tag 'blue' unsubscribe failed";
+ }
+ return test.output("data was null; we unsubscribed from the subscription " + subscription_id);
+ });
});
- };
- return Instagram.tags.subscribe({
- object_id: 'blue',
- callback_url: CALLBACK_URL,
- complete: function(data) {
- console.log("\n" + title + " subscribe#blue\n" + indent + "connection/parsing succeeded");
- try {
- data.should.have.property('id');
- data.id.should.be.above(0);
- data.should.have.property('type', 'subscription');
- console.log("" + indent + "data met assertions");
- return list(data['id']);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " subscribe#blue\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
});
},
'locations#subscriptions': function() {
- var list, title, unsubscribe;
- title = "locations#subscriptions";
- unsubscribe = function(subscription_id) {
- return Instagram.locations.unsubscribe({
- id: subscription_id,
- complete: function(data) {
- console.log("\n" + title + " unsubscribe from " + subscription_id + "\n" + indent + "connection/parsing succeeded");
- try {
- assert.isNull(data);
- console.log("" + indent + "data met assertions");
- return completed += 1;
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
+ return test.helper("locations#subscriptions subscribe to location '1257285'", Instagram, 'locations', 'subscribe', {
+ object_id: '1257285'
+ }, function(data) {
+ var subscription_id;
+ data.should.have.property('id');
+ test.output("data had the property 'id'");
+ data.id.should.be.above(0);
+ test.output("data.id was greater than 0", data.id);
+ data.should.have.property('type', 'subscription');
+ test.output("data had the property 'type' equal to 'subscription'", data);
+ subscription_id = data.id;
+ return test.helper('locations#subscriptions list', Instagram, 'subscriptions', 'list', {}, function(data) {
+ var found, i;
+ data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
+ found = false;
+ for (i in data) {
+ if (data[i].id === subscription_id) {
+ found = true;
}
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " unsubscribe\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
}
- });
- };
- list = function(subscription_id) {
- return Instagram.subscriptions.list({
- complete: function(data) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing succeeded");
- try {
- data.should.not.be.empty;
- console.log("" + indent + "data met assertions");
- return unsubscribe(subscription_id);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
+ if (!found) {
+ throw "subscription not found";
}
+ test.output("data had the subscription " + subscription_id);
+ return test.helper("locations#subscriptions unsubscribe from location '1257285'", Instagram, 'locations', 'unsubscribe', {
+ id: subscription_id
+ }, function(data) {
+ if (data !== null) {
+ throw "location '1257285' unsubscribe failed";
+ }
+ return test.output("data was null; we unsubscribed from the subscription " + subscription_id);
+ });
});
- };
- return Instagram.locations.subscribe({
- object_id: '1257285',
- callback_url: CALLBACK_URL,
- complete: function(data) {
- console.log("\n" + title + " subscribe#1257285\n" + indent + "connection/parsing succeeded");
- try {
- data.should.have.property('id');
- data.id.should.be.above(0);
- data.should.have.property('type', 'subscription');
- console.log("" + indent + "data met assertions");
- return list(data['id']);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " subscribe#1257285\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
});
},
'media#subscriptions': function() {
- var list, title, unsubscribe;
- title = "media#subscriptions";
- unsubscribe = function(subscription_id) {
- return Instagram.media.unsubscribe({
- id: subscription_id,
- complete: function(data) {
- console.log("\n" + title + " unsubscribe from " + subscription_id + "\n" + indent + "connection/parsing succeeded");
- try {
- assert.isNull(data);
- console.log("" + indent + "data met assertions");
- return completed += 1;
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " unsubscribe\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
- });
- };
- list = function(subscription_id) {
- return Instagram.subscriptions.list({
- complete: function(data) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing succeeded");
- try {
- data.should.not.be.empty;
- console.log("" + indent + "data met assertions");
- return unsubscribe(subscription_id);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
- });
- };
- return Instagram.media.subscribe({
+ return test.helper("media#subscriptions subscribe to media near Eiffel Tower", Instagram, 'media', 'subscribe', {
lat: 48.858844300000001,
lng: 2.2943506,
- radius: 1000,
- callback_url: CALLBACK_URL,
- complete: function(data) {
- console.log("\n" + title + " subscribe#48.858844300000001/2.2943506\n" + indent + "connection/parsing succeeded");
- try {
- data.should.have.property('id');
- data.id.should.be.above(0);
- data.should.have.property('type', 'subscription');
- console.log("" + indent + "data met assertions");
- return list(data['id']);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " subscribe#48.858844300000001/2.2943506\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
- });
- },
- 'subscriptions': function() {
- var list, subscribe_again, title, unsubscribe;
- title = "subscriptions";
- unsubscribe = function(ids) {
- return Instagram.subscriptions.unsubscribe_all({
- complete: function(data) {
- console.log("\n" + title + " unsubscribe_all\n" + indent + "connection/parsing succeeded");
- try {
- assert.isNull(data);
- console.log("" + indent + "data met assertions");
- return completed += 1;
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
+ radius: 1000
+ }, function(data) {
+ var subscription_id;
+ data.should.have.property('id');
+ test.output("data had the property 'id'");
+ data.id.should.be.above(0);
+ test.output("data.id was greater than 0", data.id);
+ data.should.have.property('type', 'subscription');
+ test.output("data had the property 'type' equal to 'subscription'", data);
+ subscription_id = data.id;
+ return test.helper('media#subscriptions list', Instagram, 'subscriptions', 'list', {}, function(data) {
+ var found, i;
+ data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
+ found = false;
+ for (i in data) {
+ if (data[i].id === subscription_id) {
+ found = true;
}
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " unsubscribe_all\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
}
- });
- };
- list = function(ids) {
- return Instagram.subscriptions.list({
- complete: function(data) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing succeeded");
- try {
- data.length.should.equal(2);
- console.log("" + indent + "data met assertions");
- return unsubscribe(ids);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " list\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
+ if (!found) {
+ throw "subscription not found";
}
- });
- };
- subscribe_again = function(ids) {
- return Instagram.subscriptions.subscribe({
- object: 'tag',
- object_id: 'green',
- complete: function(data) {
- console.log("\n" + title + " subscribe#green\n" + indent + "connection/parsing succeeded");
- try {
- data.should.have.property('id');
- data.id.should.be.above(0);
- data.should.have.property('type', 'subscription');
- console.log("" + indent + "data met assertions");
- ids[ids.length] = data['id'];
- return list(ids);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
+ test.output("data had the subscription " + subscription_id);
+ return test.helper("media#subscriptions unsubscribe from media near Eiffel Tower", Instagram, 'media', 'unsubscribe', {
+ id: subscription_id
+ }, function(data) {
+ if (data !== null) {
+ throw "media near Eiffel Tower unsubscribe failed";
}
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " subscribe#green\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
+ return test.output("data was null; we unsubscribed from the subscription " + subscription_id);
+ });
});
- };
- return Instagram.subscriptions.subscribe({
+ });
+ },
+ 'multi#subscriptions': function() {
+ var subscriptions;
+ subscriptions = [];
+ return test.helper("subscriptions subscribe to tag 'red'", Instagram, 'subscriptions', 'subscribe', {
object: 'tag',
- object_id: 'red',
- complete: function(data) {
- console.log("\n" + title + " subscribe#red\n" + indent + "connection/parsing succeeded");
- try {
+ object_id: 'red'
+ }, function(data) {
+ data.should.have.property('id');
+ test.output("data had the property 'id'");
+ data.id.should.be.above(0);
+ test.output("data.id was greater than 0", data.id);
+ data.should.have.property('type', 'subscription');
+ test.output("data had the property 'type' equal to 'subscription'", data);
+ subscriptions[subscriptions.length] = data.id;
+ return test.helper("subscriptions subscribe to location '1257285'", Instagram, 'subscriptions', 'subscribe', {
+ object: 'location',
+ object_id: '1257285'
+ }, function(data) {
+ data.should.have.property('id');
+ test.output("data had the property 'id'");
+ data.id.should.be.above(0);
+ test.output("data.id was greater than 0", data.id);
+ data.should.have.property('type', 'subscription');
+ test.output("data had the property 'type' equal to 'subscription'", data);
+ subscriptions[subscriptions.length] = data.id;
+ return test.helper("subscriptions subscribe to media near Eiffel Tower", Instagram, 'subscriptions', 'subscribe', {
+ object: 'geography',
+ lat: 48.858844300000001,
+ lng: 2.2943506,
+ radius: 1000
+ }, function(data) {
data.should.have.property('id');
+ test.output("data had the property 'id'");
data.id.should.be.above(0);
+ test.output("data.id was greater than 0", data.id);
data.should.have.property('type', 'subscription');
- console.log("" + indent + "data met assertions");
- return subscribe_again([data['id']]);
- } catch (e) {
- console.log("" + indent + "data failed to meet the assertion(s): " + e);
- throw e;
- }
- },
- error: function(e, data, caller) {
- console.log("\n" + title + " subscribe#red\n" + indent + "connection/parsing failed");
- console.log("" + indent + "error: " + e + "\n" + indent + "data: " + data + "\n" + indent + "caller: " + caller);
- throw e;
- }
+ test.output("data had the property 'type' equal to 'subscription'", data);
+ subscriptions[subscriptions.length] = data.id;
+ return test.helper('subscriptions list', Instagram, 'subscriptions', 'list', {}, function(data) {
+ var found, i, subscriptions_list, _ref;
+ data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
+ subscriptions_list = [];
+ for (i in data) {
+ subscriptions_list[subscriptions_list.length] = data[i].id;
+ }
+ found = true;
+ for (i in subscriptions) {
+ if (_ref = subscriptions[i], __indexOf.call(subscriptions_list, _ref) < 0) {
+ found = false;
+ }
+ }
+ if (!found) {
+ throw "subscription not found";
+ }
+ test.output("data had the subscription " + subscription_id);
+ return test.helper("subscriptions unsubscribe_all", Instagram, 'subscriptions', 'unsubscribe_all', {}, function(data) {
+ if (data !== null) {
+ throw "unsubscribe_all failed";
+ }
+ return test.output("data was null; we unsubscribed from the subscriptions " + (subscriptions_list.join(', ')));
+ });
+ });
+ });
+ });
});
}
};
View
20 test/instagram.tags.coffee
@@ -8,22 +8,32 @@ console.log "\nInstagram API Node.js Lib Tests :: Tags"
Instagram = require '../lib/class.instagram'
assert = require 'assert'
should = require 'should'
-test_helper = require './helpers.js'
+test = require './helpers.js'
module.exports =
'tags#info for blue': ->
- test_helper 'tags#info for blue', Instagram, 'tags', 'info', { name: 'blue' }, (data) ->
+ test.helper 'tags#info for blue', Instagram, 'tags', 'info', { name: 'blue' }, (data) ->
data.should.have.property 'name', 'blue'
+ test.output "data had the property 'name' equal to 'blue'"
data.media_count.should.be.above 0
+ test.output "data had the property 'media_count' greater than zero", data.media_count
'tags#recent for blue': ->
- test_helper 'tags#recent for blue', Instagram, 'tags', 'recent', { name: 'blue' }, (data, pagination) ->
+ test.helper 'tags#recent for blue', Instagram, 'tags', 'recent', { name: 'blue' }, (data, pagination) ->
data.length.should.equal 20
+ test.output "data had length equal to 20"
data[0].should.have.property 'id'
+ test.output "data[0] had the property 'id'", data[0]
pagination.should.have.property 'next_url'
+ test.output "pagination had the property 'next_url'", pagination.next_url
pagination.should.have.property 'next_max_id'
+ test.output "pagination had the property 'next_max_id'", pagination.next_max_id
pagination.should.have.property 'next_min_id'
+ test.output "pagination had the property 'next_min_id'", pagination.next_min_id
'tags#search for blue': ->
- test_helper 'tags#search for blue', Instagram, 'tags', 'search', { q: 'blue' }, (data) ->
- data.length.should.equal 50
+ test.helper 'tags#search for blue', Instagram, 'tags', 'search', { q: 'blue' }, (data) ->
+ data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
data[0].should.have.property 'name', 'blue'
+ test.output "data[0] had the property 'name' equal to 'blue'"
data[0].media_count.should.be.above 0
+ test.output "data[0] had the property 'media_count' greater than zero", data[0].media_count
View
28 test/instagram.tags.js
@@ -1,39 +1,49 @@
(function() {
/*
Testing Tag Methods
- */ var Instagram, assert, should, test_helper;
+ */ var Instagram, assert, should, test;
console.log("\nInstagram API Node.js Lib Tests :: Tags");
Instagram = require('../lib/class.instagram');
assert = require('assert');
should = require('should');
- test_helper = require('./helpers.js');
+ test = require('./helpers.js');
module.exports = {
'tags#info for blue': function() {
- return test_helper('tags#info for blue', Instagram, 'tags', 'info', {
+ return test.helper('tags#info for blue', Instagram, 'tags', 'info', {
name: 'blue'
}, function(data) {
data.should.have.property('name', 'blue');
- return data.media_count.should.be.above(0);
+ test.output("data had the property 'name' equal to 'blue'");
+ data.media_count.should.be.above(0);
+ return test.output("data had the property 'media_count' greater than zero", data.media_count);
});
},
'tags#recent for blue': function() {
- return test_helper('tags#recent for blue', Instagram, 'tags', 'recent', {
+ return test.helper('tags#recent for blue', Instagram, 'tags', 'recent', {
name: 'blue'
}, function(data, pagination) {
data.length.should.equal(20);
+ test.output("data had length equal to 20");
data[0].should.have.property('id');
+ test.output("data[0] had the property 'id'", data[0]);
pagination.should.have.property('next_url');
+ test.output("pagination had the property 'next_url'", pagination.next_url);
pagination.should.have.property('next_max_id');
- return pagination.should.have.property('next_min_id');
+ test.output("pagination had the property 'next_max_id'", pagination.next_max_id);
+ pagination.should.have.property('next_min_id');
+ return test.output("pagination had the property 'next_min_id'", pagination.next_min_id);
});
},
'tags#search for blue': function() {
- return test_helper('tags#search for blue', Instagram, 'tags', 'search', {
+ return test.helper('tags#search for blue', Instagram, 'tags', 'search', {
q: 'blue'
}, function(data) {
- data.length.should.equal(50);
+ data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
data[0].should.have.property('name', 'blue');
- return data[0].media_count.should.be.above(0);
+ test.output("data[0] had the property 'name' equal to 'blue'");
+ data[0].media_count.should.be.above(0);
+ return test.output("data[0] had the property 'media_count' greater than zero", data[0].media_count);
});
}
};
View
52 test/instagram.users.coffee
@@ -8,57 +8,69 @@ console.log "\nInstagram API Node.js Lib Tests :: Users"
Instagram = require '../lib/class.instagram'
assert = require 'assert'
should = require 'should'
-test_helper = require './helpers.js'
+test = require './helpers.js'
module.exports =
'users#info for id#291024': ->
- test_helper 'users#info for id#291024', Instagram, 'users', 'info', { user_id: 291024 }, (data) ->
+ test.helper 'users#info for id#291024', Instagram, 'users', 'info', { user_id: 291024 }, (data) ->
data.should.have.property 'id', '291024'
+ test.output "data had the property 'id' equal to '291024'"
data.should.have.property 'profile_picture'
+ test.output "data had the property 'profile_picture'", data.profile_picture
'users#self for mckelvey': ->
- test_helper 'users#self for mckelvey', Instagram, 'users', 'self', {}, (data) ->
+ test.helper 'users#self for mckelvey', Instagram, 'users', 'self', {}, (data) ->
data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
data[0].should.have.property 'id'
+ test.output "data[0] had the property 'id'", data[0].id
data[0].should.have.property 'user'
+ test.output "data[0] had the property 'user'", data[0].user
'users#recent for mckelvey': ->
- test_helper 'users#recent for mckelvey', Instagram, 'users', 'recent', { user_id: 291024 }, (data) ->
+ test.helper 'users#recent for mckelvey', Instagram, 'users', 'recent', { user_id: 291024 }, (data) ->
data.length.should.be.above 0
data[0].should.have.property 'id'
data[0]['user'].should.have.property 'username', 'mckelvey'
'users#search for mckelvey': ->
- test_helper 'users#search for mckelvey', Instagram, 'users', 'search', { q: 'mckelvey' }, (data) ->
+ test.helper 'users#search for mckelvey', Instagram, 'users', 'search', { q: 'mckelvey' }, (data) ->
data.length.should.be.above 0
+ test.output "data had length greater than 0", data.length
data[0].should.have.property 'username', 'mckelvey'
+ test.output "data had the property 'username' equal to 'mckelvey'"
data[0].should.have.property 'id', '291024'
+ test.output "data had the property 'id' equal to '291024'"
'users#follows id#291024': ->
- test_helper 'users#follows id#291024', Instagram, 'users', 'follows', { user_id: 291024 }, (data, pagination) ->
+ test.helper 'users#follows id#291024', Instagram, 'users', 'follows', { user_id: 291024 }, (data, pagination) ->
data.length.should.be.above 0
data.length.should.be.below 51
'users#followed_by id#291024': ->
- test_helper 'users#followed_by id#291024', Instagram, 'users', 'followed_by', { user_id: 291024 }, (data, pagination) ->
+ test.helper 'users#followed_by id#291024', Instagram, 'users', 'followed_by', { user_id: 291024 }, (data, pagination) ->
data.length.should.be.above 0
+ test.output "data had length greater than 0"
data.length.should.be.below 51
+ test.output "data had length less than 51", data.length
'users#requested_by id#291024': ->
- test_helper 'users#requested_by id#291024', Instagram, 'users', 'requested_by', { user_id: 291024 }, (data, pagination) ->
+ test.helper 'users#requested_by id#291024', Instagram, 'users', 'requested_by', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'length'
+ test.output "data had the property 'length'", data.length
'users#relationship with id#291024': ->
- test_helper 'users#relationship with id#291024', Instagram, 'users', 'relationship', { user_id: 291024 }, (data, pagination) ->
+ test.helper 'users#relationship with id#291024', Instagram, 'users', 'relationship', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'outgoing_status'
+ test.output "data had the property 'outgoing_status'", data.outgoing_status
data.should.have.property 'incoming_status'
- console.log " outgoing: #{data['outgoing_status']}, incoming: #{data['incoming_status']}"
+ test.output "data had the property 'incoming_status'", data.incoming_status
'users#unfollow id#291024': ->
- test_helper 'users#unfollow id#291024', Instagram, 'users', 'unfollow', { user_id: 291024 }, (data, pagination) ->
+ test.helper 'users#unfollow id#291024', Instagram, 'users', 'unfollow', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'outgoing_status', 'none'
- console.log " outgoing: #{data['outgoing_status']}, incoming: #{data['incoming_status']}"
- test_helper 'users#block id#291024', Instagram, 'users', 'block', { user_id: 291024 }, (data, pagination) ->
+ test.output "data had the property 'outgoing_status' equal to 'none'", data
+ test.helper 'users#block id#291024', Instagram, 'users', 'block', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'incoming_status', 'blocked_by_you'
- console.log " outgoing: #{data['outgoing_status']}, incoming: #{data['incoming_status']}"
- test_helper 'users#unblock id#291024', Instagram, 'users', 'unblock', { user_id: 291024 }, (data, pagination) ->
+ test.output "data had the property 'incoming_status' equal to 'blocked_by_you'", data
+ test.helper 'users#unblock id#291024', Instagram, 'users', 'unblock', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'incoming_status', 'none'
- console.log " outgoing: #{data['outgoing_status']}, incoming: #{data['incoming_status']}"
- test_helper 'users#ignore id#291024', Instagram, 'users', 'ignore', { user_id: 291024 }, (data, pagination) ->
+ test.output "data had the property 'incoming_status' equal to 'none'", data
+ test.helper 'users#ignore id#291024', Instagram, 'users', 'ignore', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'incoming_status', 'none'
- console.log " outgoing: #{data['outgoing_status']}, incoming: #{data['incoming_status']}"
- test_helper 'users#follow id#291024', Instagram, 'users', 'follow', { user_id: 291024 }, (data, pagination) ->
+ test.output "data had the property 'incoming_status' equal to 'none'", data
+ test.helper 'users#follow id#291024', Instagram, 'users', 'follow', { user_id: 291024 }, (data, pagination) ->
data.should.have.property 'outgoing_status', 'follows'
- console.log " outgoing: #{data['outgoing_status']}, incoming: #{data['incoming_status']}"
+ test.output "data had the property 'outgoing_status' equal to 'follows'", data
View
64 test/instagram.users.js
@@ -1,30 +1,35 @@
(function() {
/*
Testing Users Methods
- */ var Instagram, assert, should, test_helper;
+ */ var Instagram, assert, should, test;
console.log("\nInstagram API Node.js Lib Tests :: Users");
Instagram = require('../lib/class.instagram');
assert = require('assert');
should = require('should');
- test_helper = require('./helpers.js');
+ test = require('./helpers.js');
module.exports = {
'users#info for id#291024': function() {
- return test_helper('users#info for id#291024', Instagram, 'users', 'info', {
+ return test.helper('users#info for id#291024', Instagram, 'users', 'info', {
user_id: 291024
}, function(data) {
data.should.have.property('id', '291024');
- return data.should.have.property('profile_picture');
+ test.output("data had the property 'id' equal to '291024'");
+ data.should.have.property('profile_picture');
+ return test.output("data had the property 'profile_picture'", data.profile_picture);
});
},
'users#self for mckelvey': function() {
- return test_helper('users#self for mckelvey', Instagram, 'users', 'self', {}, function(data) {
+ return test.helper('users#self for mckelvey', Instagram, 'users', 'self', {}, function(data) {
data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
data[0].should.have.property('id');
- return data[0].should.have.property('user');
+ test.output("data[0] had the property 'id'", data[0].id);
+ data[0].should.have.property('user');
+ return test.output("data[0] had the property 'user'", data[0].user);
});
},
'users#recent for mckelvey': function() {
- return test_helper('users#recent for mckelvey', Instagram, 'users', 'recent', {
+ return test.helper('users#recent for mckelvey', Instagram, 'users', 'recent', {
user_id: 291024
}, function(data) {
data.length.should.be.above(0);
@@ -33,16 +38,19 @@
});
},
'users#search for mckelvey': function() {
- return test_helper('users#search for mckelvey', Instagram, 'users', 'search', {
+ return test.helper('users#search for mckelvey', Instagram, 'users', 'search', {
q: 'mckelvey'
}, function(data) {
data.length.should.be.above(0);
+ test.output("data had length greater than 0", data.length);
data[0].should.have.property('username', 'mckelvey');
- return data[0].should.have.property('id', '291024');
+ test.output("data had the property 'username' equal to 'mckelvey'");
+ data[0].should.have.property('id', '291024');
+ return test.output("data had the property 'id' equal to '291024'");
});
},
'users#follows id#291024': function() {
- return test_helper('users#follows id#291024', Instagram, 'users', 'follows', {
+ return test.helper('users#follows id#291024', Instagram, 'users', 'follows', {
user_id: 291024
}, function(data, pagination) {
data.length.should.be.above(0);
@@ -50,55 +58,59 @@
});
},
'users#followed_by id#291024': function() {
- return test_helper('users#followed_by id#291024', Instagram, 'users', 'followed_by', {
+ return test.helper('users#followed_by id#291024', Instagram, 'users', 'followed_by', {
user_id: 291024
}, function(data, pagination) {
data.length.should.be.above(0);
- return data.length.should.be.below(51);
+ test.output("data had length greater than 0");
+ data.length.should.be.below(51);
+ return test.output("data had length less than 51", data.length);
});
},
'users#requested_by id#291024': function() {
- return test_helper('users#requested_by id#291024', Instagram, 'users', 'requested_by', {
+ return test.helper('users#requested_by id#291024', Instagram, 'users', 'requested_by', {
user_id: 291024
}, function(data, pagination) {
- return data.should.have.property('length');
+ data.should.have.property('length');
+ return test.output("data had the property 'length'", data.length);
});
},
'users#relationship with id#291024': function() {
- return test_helper('users#relationship with id#291024', Instagram, 'users', 'relationship', {
+ return test.helper('users#relationship with id#291024', Instagram, 'users', 'relationship', {
user_id: 291024
}, function(data, pagination) {
data.should.have.property('outgoing_status');
+ test.output("data had the property 'outgoing_status'", data.outgoing_status);
data.should.have.property('incoming_status');
- return console.log(" outgoing: " + data['outgoing_status'] + ", incoming: " + data['incoming_status']);
+ return test.output("data had the property 'incoming_status'", data.incoming_status);
});
},
'users#unfollow id#291024': function() {
- return test_helper('users#unfollow id#291024', Instagram, 'users', 'unfollow', {
+ return test.helper('users#unfollow id#291024', Instagram, 'users', 'unfollow', {
user_id: 291024
}, function(data, pagination) {
data.should.have.property('outgoing_status', 'none');
- console.log(" outgoing: " + data['outgoing_status'] + ", incoming: " + data['incoming_status']);
- return test_helper('users#block id#291024', Instagram, 'users', 'block', {
+ test.output("data had the property 'outgoing_status' equal to 'none'", data);
+ return test.helper('users#block id#291024', Instagram, 'users', 'block', {
user_id: 291024
}, function(data, pagination) {
data.should.have.property('incoming_status', 'blocked_by_you');
- console.log(" outgoing: " + data['outgoing_status'] + ", incoming: " + data['incoming_status']);
- return test_helper('users#unblock id#291024', Instagram, 'users', 'unblock', {
+ test.output("data had the property 'incoming_status' equal to 'blocked_by_you'", data);
+ return test.helper('users#unblock id#291024', Instagram, 'users', 'unblock', {
user_id: 291024
}, function(data, pagination) {
data.should.have.property('incoming_status', 'none');
- console.log(" outgoing: " + data['outgoing_status'] + ", incoming: " + data['incoming_status']);
- return test_helper('users#ignore id#291024', Instagram, 'users', 'ignore', {
+ test.output("data had the property 'incoming_status' equal to 'none'", data);
+ return test.helper('users#ignore id#291024', Instagram, 'users', 'ignore', {
user_id: 291024
}, function(data, pagination) {
data.should.have.property('incoming_status', 'none');
- console.log(" outgoing: " + data['outgoing_status'] + ", incoming: " + data['incoming_status']);
- return test_helper('users#follow id#291024', Instagram, 'users', 'follow', {
+ test.output("data had the property 'incoming_status' equal to 'none'", data);
+ return test.helper('users#follow id#291024', Instagram, 'users', 'follow', {
user_id: 291024
}, function(data, pagination) {
data.should.have.property('outgoing_status', 'follows');
- return console.log(" outgoing: " + data['outgoing_status'] + ", incoming: " + data['incoming_status']);
+ return test.output("data had the property 'outgoing_status' equal to 'follows'", data);
});
});
});

0 comments on commit 29316b9

Please sign in to comment.
Something went wrong with that request. Please try again.