Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update tests, fix api_key for remove call

  • Loading branch information...
commit a26e7f54342a55aa98f42546ecc0c1695e8da184 1 parent 71fbab3
@mitechie mitechie authored
View
12 extensions/chrome_ext/lib/bookie.api.js
@@ -164,12 +164,20 @@ var bookie = (function (opts) {
};
+ /**
+ * By default a delete will have the data() passed into the POST, so we
+ * need to manually override the api_key into the url ourselves
+ *
+ */
$b.api.remove = function (hash_id, callbacks) {
- var url = "/api/v1/%s/bmark/" + hash_id,
+ var url = "/api/v1/%s/bmark/" + _.sprintf("%s?api_key=%s",
+ hash_id,
+ $b.api.opt.api_key),
opts = {
url: url,
type: "delete",
- success: callbacks.success
+ success: callbacks.success,
+ error: callbacks.error
};
$b.api._request(opts);
View
58 extensions/tests/test_bookie.api.js
@@ -43,7 +43,8 @@ var API_URL = 'http://dev.bmark.us',
HASH_ID = 'c5c21717c99797',
FAILED = function (data, status_string) {
// if we hit this the request failed in a bad way
- console.log(data);
+ console.log(_.keys(data));
+ console.log(_.values(data));
console.log(status_string);
ok(false, "Shouldn't have a bad api requests here");
@@ -59,7 +60,6 @@ test('live.bookmark', function () {
// we're going to test both with and without content so two calls
expect(2);
- console.log('bookmark');
stop();
bookie.api.init(API_URL, USERNAME, API_KEY);
@@ -88,8 +88,6 @@ test('live.bookmark_readable', function () {
stop();
bookie.api.init(API_URL, USERNAME, API_KEY);
- console.log('readable');
-
bookie.api.bookmark(HASH_ID, {
'get_last': false,
'with_content': true,
@@ -119,8 +117,6 @@ test('live.recent', function () {
stop();
bookie.api.init(API_URL, USERNAME, API_KEY);
- console.log('recent');
-
bookie.api.recent({
'count': 10,
'page': 0,
@@ -152,8 +148,6 @@ test('live.popular', function () {
stop();
bookie.api.init(API_URL, USERNAME, API_KEY);
- console.log('popular');
-
bookie.api.popular({
'count': 5,
'page': 0,
@@ -197,13 +191,17 @@ test('live.add', function () {
bookie.api.add(TEST_BMARK, {
'success': function (data) {
- console.log(data);
ok(data.bmark !== undefined,
"We should have a bookmark returned");
ok(data.bmark.hash_id == TEST_HASH,
"We should have the correct hash id: " + data.bmark.hash_id);
- ok(data.location == _.sprintf("%s/bmark/readable/%s",
+
+ // the dev install has a double slash after the hostname, I can't
+ // for the life of me figure out why. The current live site
+ // doesn't. Same setup, same hosting, same nginx, wsgi.py, .ini
+ // configs. Baffled.
+ ok(data.location == _.sprintf("%s//bmark/readable/%s",
API_URL,
TEST_HASH),
"We should have a location that's correct: " + data.location);
@@ -223,28 +221,18 @@ test('live.add', function () {
* test for add, if it fails, well it's probably because add failed.
*
*/
-// test('live.popular', function () {
-// expect(3)
-//
-// stop();
-// bookie.api.init(API_URL, USERNAME, API_KEY);
-//
-// bookie.api.popular({
-// 'count': 5,
-// 'page': 0,
-// },
-// {
-// 'success': function (data) {
-// ok(data.count == 5,
-// "We need to get 5 bookmarks");
-// ok(data.bmarks[0].hash_id !== undefined,
-// "Should have readable content");
-// ok(data.bmarks[0].readable === undefined,
-// "Should not have content by default");
-//
-// start();
-//
-// },
-// 'error': FAILED
-// });
-// });
+test('live.add', function () {
+ expect(1)
+
+ stop();
+ bookie.api.init(API_URL, USERNAME, API_KEY);
+
+ bookie.api.remove(TEST_HASH, {
+ 'success': function (data) {
+ ok(_.isEqual(data, {'message': 'done'}),
+ "Should have a message of done: " + data.message);
+ start();
+ },
+ 'error': FAILED
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.