From bbe332bde29329f868f02164bf73fdcde09606dc Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Wed, 16 Dec 2015 17:23:30 +0000 Subject: [PATCH 1/3] Make `Bulk.toString()` actually return a string Before this change it returns an object, which seems confusing. --- lib/bulk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bulk.js b/lib/bulk.js index 2148904..5a343d4 100644 --- a/lib/bulk.js +++ b/lib/bulk.js @@ -138,7 +138,7 @@ Bulk.prototype.tojson = function () { } Bulk.prototype.toString = function () { - return this.tojson() + return JSON.stringify(this.tojson()) } Bulk.prototype.execute = function (cb) { From 449a691a1091cf7540014b35fd583ebdd22cfe92 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Fri, 18 Dec 2015 16:58:51 +0000 Subject: [PATCH 2/3] Fix test for bulk.toString --- test/test-to-string-bulk.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test-to-string-bulk.js b/test/test-to-string-bulk.js index 53c6be5..c7a2d17 100644 --- a/test/test-to-string-bulk.js +++ b/test/test-to-string-bulk.js @@ -1,6 +1,6 @@ var insert = require('./insert') -insert('bulk to json', [{ +insert('bulk to string', [{ name: 'Squirtle', type: 'water' }, { name: 'Starmie', type: 'water' @@ -20,6 +20,8 @@ insert('bulk to json', [{ bulk.find({ status: 'D' }).removeOne() var result = bulk.toString() + t.equals(typeof result, 'string', 'bulk.toString() should return a string'); + result = JSON.parse(result); t.equals(result.nInsertOps, 2, 'Should result in nInsertOps field set to 2') t.equals(result.nUpdateOps, 1, 'Should result in nUpdateOps field set to 1') t.equals(result.nRemoveOps, 1, 'Should result in nRemoveOps field set to 1') From e0a4d8d6dcf348cf0e807fe4f67d2e8c540b3036 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay Date: Thu, 14 Jan 2016 13:50:09 +0000 Subject: [PATCH 3/3] Remove semicolons --- test/test-to-string-bulk.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-to-string-bulk.js b/test/test-to-string-bulk.js index c7a2d17..977c0f3 100644 --- a/test/test-to-string-bulk.js +++ b/test/test-to-string-bulk.js @@ -20,8 +20,8 @@ insert('bulk to string', [{ bulk.find({ status: 'D' }).removeOne() var result = bulk.toString() - t.equals(typeof result, 'string', 'bulk.toString() should return a string'); - result = JSON.parse(result); + t.equals(typeof result, 'string', 'bulk.toString() should return a string') + result = JSON.parse(result) t.equals(result.nInsertOps, 2, 'Should result in nInsertOps field set to 2') t.equals(result.nUpdateOps, 1, 'Should result in nUpdateOps field set to 1') t.equals(result.nRemoveOps, 1, 'Should result in nRemoveOps field set to 1')