Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Lint (not done)

  • Loading branch information...
commit 972f06e95e091bec95604a23feb5a8a4752dd9cb 1 parent bb91169
@cjohansen cjohansen authored
View
22 autolint.js
@@ -0,0 +1,22 @@
+module.exports = {
+ paths: [
+ "lib/*.js",
+ "test/*.js"
+ ],
+ linterOptions: {
+ node: true,
+ browser: true,
+ plusplus: true,
+ sloppy: true,
+ vars: true,
+ es5: true,
+ nomen: true,
+ forin: true,
+ predef: [
+ "define",
+ "assert",
+ "refute",
+ "buster"
+ ]
+ }
+};
View
23 test/fs-filtered-test.js
@@ -10,12 +10,25 @@ function f() { return false; }
buster.testCase('fs-filtered', {
setUp: function () {
- this.stub(fs, "readdir").yields(null, ["mydir", "f1.js", "f2.md", ".#meh"]);
+ var files = ["mydir", "f1.js", "f2.md", ".#meh"];
+ this.stub(fs, "readdir").yields(null, files);
this.stub(fs, "stat");
- fs.stat.withArgs(p("tmp", "mydir")).yields(null, { stats: "oh", isDirectory: t });
- fs.stat.withArgs(p("tmp", "f1.js")).yields(null, { stats: "yo", isDirectory: f });
- fs.stat.withArgs(p("tmp", "f2.md")).yields(null, { stats: "ho", isDirectory: f });
- fs.stat.withArgs(p("tmp", ".#meh")).yields(null, { stats: "no", isDirectory: f });
+ fs.stat.withArgs(p("tmp", "mydir")).yields(null, {
+ stats: "oh",
+ isDirectory: t
+ });
+ fs.stat.withArgs(p("tmp", "f1.js")).yields(null, {
+ stats: "yo",
+ isDirectory: f
+ });
+ fs.stat.withArgs(p("tmp", "f2.md")).yields(null, {
+ stats: "ho",
+ isDirectory: f
+ });
+ fs.stat.withArgs(p("tmp", ".#meh")).yields(null, {
+ stats: "no",
+ isDirectory: f
+ });
},
"stats all files in a directory": function () {
View
10 test/helper.js
@@ -7,12 +7,12 @@ module.exports = {
mktreeSync: function mktreeSync(tree, root) {
root = root || module.exports.ROOT;
- var file;
+ var file, prop;
- for (var prop in tree) {
+ for (prop in tree) {
file = path.join(root, prop);
- if (typeof tree[prop] == "object") {
+ if (typeof tree[prop] === "object") {
fs.mkdirSync(file, "0755");
mktreeSync(tree[prop], file);
} else {
@@ -25,10 +25,10 @@ module.exports = {
mktree: function mktree(tree, root) {
root = root || module.exports.ROOT;
- var file, d;
+ var file, d, prop;
var promises = [];
- for (var prop in tree) {
+ for (prop in tree) {
d = when.defer();
file = path.join(root, prop);
View
15 test/os-watch-helper.js
@@ -33,15 +33,19 @@ var dir = path.dirname;
var unique = new Date().getTime();
var noop = function () {};
-var is = function (file) { return function (watcher) { return file === watcher.file; }; };
+var is = function (file) {
+ return function (watcher) { return file === watcher.file; };
+};
-var notEq = function (watcher) { return function (w) { return w !== watcher; }; };
+var notEq = function (watcher) {
+ return function (w) { return w !== watcher; };
+};
function removeWatcher(watcher) {
this.watchers = this.watchers.filter(notEq(watcher));
}
-function watch (file, callback) {
+function watch(file, callback) {
var watcher = {
file: file,
callback: callback
@@ -50,9 +54,9 @@ function watch (file, callback) {
return { close: removeWatcher.bind(this, watcher) };
}
-function event(file, event, info) {
+function event(file, e, info) {
return when.all(this.watchers.filter(is(file)).map(function (watcher) {
- return watcher.callback(event, info);
+ return watcher.callback(e, info);
}));
}
@@ -207,6 +211,7 @@ module.exports = {
},
get watchers() { return this.os.watchers; },
+ set watchers(value) { throw new Error("Property is not writable"); },
change: function (file) {
var d = when.defer(), os = this.os;
View
14 test/walk-tree-test.js
@@ -7,12 +7,7 @@ var helper = require("./helper");
function walkTreeTest(options) {
return function (done) {
- var root = helper.mktreeSync(options.tree);
-
- var callback = this.spy(function () {
- if (callback.callCount != options.expected.length) return;
- setTimeout(verify, 10);
- });
+ var callback, root = helper.mktreeSync(options.tree);
function verify() {
assert.equals(callback.callCount, options.expected.length);
@@ -24,6 +19,11 @@ function walkTreeTest(options) {
done();
}
+ callback = this.spy(function () {
+ if (callback.callCount !== options.expected.length) { return; }
+ setTimeout(verify, 10);
+ });
+
if (options.exclude) {
fsu.walkTree(root, { exclude: options.exclude }, callback);
} else {
@@ -69,7 +69,7 @@ buster.testCase("walk-tree", {
}
}),
- "should not yield excluded directories by regexp to callback": walkTreeTest({
+ "should not yield excluded directories by regexp": walkTreeTest({
expected: ["/projects", "/documents"],
exclude: ["music"],
tree: {
View
9 test/watch-tree-unix-test.js
@@ -11,8 +11,9 @@ function p(filePath) {
}
function assertWatched(spy, path) {
- for (var i = 0, l = spy.callCount; i < l; ++i) {
- if (spy.getCall(i).args[0] == path) {
+ var i, l;
+ for (i = 0, l = spy.callCount; i < l; ++i) {
+ if (spy.getCall(i).args[0] === path) {
buster.assertions.emit("pass");
return true;
}
@@ -29,7 +30,7 @@ function watchTest(options) {
var self = this;
this.onWatch = function () {
- if (fs.watch.callCount == this.expectedCount) {
+ if (fs.watch.callCount === this.expectedCount) {
setTimeout(function () {
options.assert.call(self);
done();
@@ -54,7 +55,7 @@ function eventTest(options) {
},
assert: function () {
- var ev = options && options.event || {};
+ var ev = (options && options.event) || {};
fs.watch.args[0][1](ev.type, ev.file);
options.assert.call(this);
}

0 comments on commit 972f06e

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