Skip to content

Commit

Permalink
Undoing a recent change to set(), creating a test for an existing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Oct 15, 2015
1 parent 19f99af commit 2589dc2
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haro",
"version": "1.7.5",
"version": "1.7.8",
"homepage": "http://haro.rocks",
"authors": [
"Jason Mulligan <jason.mulligan@avoidwork.com>"
Expand Down
10 changes: 4 additions & 6 deletions lib/haro.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2015
* @license BSD-3-Clause
* @link http://haro.rocks
* @version 1.7.7
* @version 1.7.8
*/
"use strict";

Expand Down Expand Up @@ -770,10 +770,8 @@ class Haro {
}

if (method === "post") {
if (!this.data.has(lkey)) {
this.registry[this.total] = lkey;
++this.total;
}
this.registry[this.total] = lkey;
++this.total;

if (this.versioning) {
this.versions.set(lkey, new Set());
Expand Down Expand Up @@ -1109,7 +1107,7 @@ function factory (data = null, config = {}, indexes = []) {
}

factory.transform = cast;
factory.version = "1.7.7";
factory.version = "1.7.8";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
10 changes: 4 additions & 6 deletions lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2015
* @license BSD-3-Clause
* @link http://haro.rocks
* @version 1.7.7
* @version 1.7.8
*/
"use strict";

Expand Down Expand Up @@ -864,10 +864,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}

if (method === "post") {
if (!_this10.data.has(lkey)) {
_this10.registry[_this10.total] = lkey;
++_this10.total;
}
_this10.registry[_this10.total] = lkey;
++_this10.total;

if (_this10.versioning) {
_this10.versions.set(lkey, new Set());
Expand Down Expand Up @@ -1241,7 +1239,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}

factory.transform = cast;
factory.version = "1.7.7";
factory.version = "1.7.8";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion lib/haro.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/haro.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haro",
"version": "1.7.7",
"version": "1.7.8",
"description": "Harō is a modern immutable DataStore using Maps, Sets, Promises, & Tuples",
"main": "lib/haro.js",
"scripts": {
Expand Down
6 changes: 2 additions & 4 deletions src/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,8 @@ class Haro {
}

if (method === "post") {
if (!this.data.has(lkey)) {
this.registry[this.total] = lkey;
++this.total;
}
this.registry[this.total] = lkey;
++this.total;

if (this.versioning) {
this.versions.set(lkey, new Set());
Expand Down
44 changes: 44 additions & 0 deletions test/haro_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,50 @@ exports["create (batch)"] = {
}
};

exports["update (batch)"] = {
setUp: function (done) {
this.store = haro();
done();
},
test: function (test) {
var self = this;

test.expect(14);
test.equal(this.store.total, 0, "Should be '0'");
test.equal(this.store.data.size, 0, "Should be '0'");
this.store.batch(data, "set").then(function () {
test.equal(self.store.total, 6, "Should be '6'");
test.equal(self.store.data.size, 6, "Should be '6'");
test.equal(self.store.registry.length, 6, "Should be '6'");
return self.store.batch(data, "set");
}, function (e) {
throw e;
}).then(function () {
test.equal(self.store.total, 6, "Should be '6'");
test.equal(self.store.data.size, 6, "Should be '6'");
test.equal(self.store.registry.length, 6, "Should be '6'");
test.equal(self.store.limit(2)[1][0], self.store.get(self.store.registry[1])[0], "Should be a match");
test.equal(self.store.limit(2, 2)[1][0], self.store.get(self.store.registry[3])[0], "Should be a match");
test.equal(self.store.limit(10, 5).length, 1, "Should be '1'");
test.equal(self.store.filter(function (i) {
return /decker/i.test(i.name);
}).length, 1, "Should be '1'");
test.equal(self.store.map(function (i) {
i.name = 'John Doe';
return i;
}).length, 6, "Should be '6'");
test.equal(self.store.map(function (i) {
i.name = 'John Doe';
return i;
})[0].name, 'John Doe', "Should be a match");
test.done();
}, function (e) {
console.log(e.stack);
test.done();
});
}
};

exports["read (valid)"] = {
setUp: function (done) {
this.store = haro();
Expand Down

0 comments on commit 2589dc2

Please sign in to comment.