Skip to content

Commit

Permalink
Splitting tests up for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Nov 19, 2016
1 parent ab5572d commit f99db38
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 136 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- "7.0"
- "6.0"
- node
- 7
- 6

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = function (grunt) {
}
},
eslint: {
target: ["lib/<%= pkg.name %>.es6.js", "test/haro_test.js"]
target: ["lib/<%= pkg.name %>.es6.js", "test/*.js"]
},
nodeunit : {
all : ["test/*.js"]
Expand Down
4 changes: 2 additions & 2 deletions lib/haro.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2016
* @license BSD-3-Clause
* @link https://github.com/avoidwork/haro
* @version 3.0.5
* @version 3.0.6
*/
"use strict";

Expand Down Expand Up @@ -1259,7 +1259,7 @@
}

factory.transform = cast;
factory.version = "3.0.5";
factory.version = "3.0.6";

// Node, AMD & window supported
if (typeof exports !== "undefined") {
Expand Down
4 changes: 2 additions & 2 deletions lib/haro.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @copyright 2016
* @license BSD-3-Clause
* @link https://github.com/avoidwork/haro
* @version 3.0.5
* @version 3.0.6
*/
"use strict";

Expand Down Expand Up @@ -1428,7 +1428,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}

factory.transform = cast;
factory.version = "3.0.5";
factory.version = "3.0.6";

// 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.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"devDependencies": {
"babel-preset-es2015": "~6.18.0",
"grunt": "~1.0.1",
"grunt": "~0.4.5",
"grunt-babel": "^6.0.0",
"grunt-cli": "^0.1.13",
"grunt-contrib-concat": "~1.0.1",
Expand All @@ -41,11 +41,11 @@
"grunt-eslint": "~19.0.0",
"grunt-sed": "^0.1.1",
"precise": "^1.0.1",
"tenso": "~1.5.1"
"tenso": "~4.0.6"
},
"dependencies": {
"Blob": "~0.10.0",
"node-fetch": "~1.6.1",
"node-fetch": "~1.6.3",
"tiny-defer": "~2.0.0",
"tiny-tuple": "~1.0.8",
"tiny-worker": "~1.1.5"
Expand Down
124 changes: 0 additions & 124 deletions test/haro_test.js → test/offline.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
var haro = require("../lib/haro"),
data = require("./data.json");

require("tenso")({
security: {
csrf: false
},
logs: {
level: "warn"
},
routes: {
get: {
"/data.*": function (req, res) {
res.respond(data);
}
},
put: {
"/data.*": function (req, res) {
res.respond(req.body);
}
},
post: {
"/data.*": function (req, res) {
res.respond(req.body, 201);
}
},
"delete": {
"/data.*": function (req, res) {
res.respond({success: true});
}
}
}
});

exports.empty = {
setUp: function (done) {
this.store = haro(null, {key: "guid", logging: false});
Expand Down Expand Up @@ -679,96 +648,3 @@ exports["override (records)"] = {
});
}
};

exports.setUri = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
done();
},
test: function (test) {
var self = this;

test.expect(5);
test.equal(this.store.total, 0, "Should be '0'");
test.equal(this.store.data.size, 0, "Should be '0'");
this.store.setUri("http://localhost:8000/data?page_size=10").then(function (args) {
test.equal(args.length, 6, "Should be '6'");
test.equal(self.store.total, 6, "Should be '6'");
test.equal(self.store.data.size, 6, "Should be '6'");
test.done();
}, function () {
test.done();
});
}
};

exports["create (wired)"] = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
this.record = JSON.parse(JSON.stringify(data[0]));
this.record.id = "8385ac94-0ebf-4a83-a6ba-25b54ce343be";
done();
},
test: function (test) {
var self = this;

test.expect(1);
this.store.setUri("http://localhost:8000/data/?page_size=10").then(function () {
return self.store.set(null, self.record);
}, function (e) {
throw e;
}).then(function (arg) {
test.equal(arg[0], self.record.id, "Should be a match");
test.done();
}, function () {
test.done();
});
}
};

exports["delete (wired)"] = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
done();
},
test: function (test) {
var self = this;

test.expect(3);
this.store.setUri("http://localhost:8000/data/?page_size=10").then(function (args) {
test.equal(self.store.total, 6, "Should be a match");

return self.store.del(args[0][0]);
}, function (e) {
throw e;
}).then(function () {
test.equal(self.store.total, self.store.data.size, "Should be a match");
test.equal(self.store.data.size, 5, "Should be a match");
test.done();
}, function () {
test.done();
});
}
};

exports["update (wired / overwrite)"] = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
done();
},
test: function (test) {
var self = this;

test.expect(1);
this.store.setUri("http://localhost:8000/data?page_size=10").then(function (args) {
return self.store.set(args[0][0], {blah: true}, false, true);
}, function (e) {
throw e;
}).then(function (arg) {
test.equal(Object.keys(arg[1]).length, 1, "Should be a match");
test.done();
}, function () {
test.done();
});
}
};
126 changes: 126 additions & 0 deletions test/online.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
var haro = require("../lib/haro"),
data = require("./data.json");

require("tenso")({
security: {
csrf: false
},
logs: {
level: "warn"
},
routes: {
get: {
"/data.*": function (req, res) {
res.respond(data);
}
},
put: {
"/data.*": function (req, res) {
res.respond(req.body);
}
},
post: {
"/data.*": function (req, res) {
res.respond(req.body, 201);
}
},
"delete": {
"/data.*": function (req, res) {
res.respond({success: true});
}
}
}
});

exports.setUri = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
done();
},
test: function (test) {
var self = this;

test.expect(5);
test.equal(this.store.total, 0, "Should be '0'");
test.equal(this.store.data.size, 0, "Should be '0'");
this.store.setUri("http://localhost:8000/data?page_size=10").then(function (args) {
test.equal(args.length, 6, "Should be '6'");
test.equal(self.store.total, 6, "Should be '6'");
test.equal(self.store.data.size, 6, "Should be '6'");
test.done();
}, function () {
test.done();
});
}
};

exports["create (wired)"] = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
this.record = JSON.parse(JSON.stringify(data[0]));
this.record.id = "8385ac94-0ebf-4a83-a6ba-25b54ce343be";
done();
},
test: function (test) {
var self = this;

test.expect(1);
this.store.setUri("http://localhost:8000/data/?page_size=10").then(function () {
return self.store.set(null, self.record);
}, function (e) {
throw e;
}).then(function (arg) {
test.equal(arg[0], self.record.id, "Should be a match");
test.done();
}, function () {
test.done();
});
}
};

exports["delete (wired)"] = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
done();
},
test: function (test) {
var self = this;

test.expect(3);
this.store.setUri("http://localhost:8000/data/?page_size=10").then(function (args) {
test.equal(self.store.total, 6, "Should be a match");

return self.store.del(args[0][0]);
}, function (e) {
throw e;
}).then(function () {
test.equal(self.store.total, self.store.data.size, "Should be a match");
test.equal(self.store.data.size, 5, "Should be a match");
test.done();
}, function () {
test.done();
});
}
};

exports["update (wired / overwrite)"] = {
setUp: function (done) {
this.store = haro(null, {key: "guid", source: "data.result", logging: false});
done();
},
test: function (test) {
var self = this;

test.expect(1);
this.store.setUri("http://localhost:8000/data?page_size=10").then(function (args) {
return self.store.set(args[0][0], {blah: true}, false, true);
}, function (e) {
throw e;
}).then(function (arg) {
test.equal(Object.keys(arg[1]).length, 1, "Should be a match");
test.done();
}, function () {
test.done();
});
}
};

0 comments on commit f99db38

Please sign in to comment.