Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

travis-ci, mocha for tests

  • Loading branch information...
commit dee3483bbcc7e76f247d023820f734e864e9529d 1 parent 3d1fc51
@daaku authored
Showing with 37 additions and 36 deletions.
  1. +3 −0  .travis.yml
  2. +3 −3 package.json
  3. +1 −1  readme.md
  4. +30 −32 test/walker.js
View
3  .travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - 0.6
View
6 package.json
@@ -10,12 +10,12 @@
"type": "git",
"url": "https://github.com/nshah/nodejs-walker"
},
- "scripts": { "test": "./node_modules/.bin/expresso -c" },
+ "scripts": { "test": "NODE_PATH=./lib ./node_modules/.bin/mocha --ui exports" },
"dependencies": {
"makeerror": ">= 1.0.0"
},
"devDependencies": {
- "expresso": ">= 0.8.1"
+ "mocha": ">= 0.12.0"
},
- "engines": { "node": ">= 0.4.1" }
+ "engines": { "node": ">= 0.6.10" }
}
View
2  readme.md
@@ -1,4 +1,4 @@
-walker
+walker [![Build Status](https://secure.travis-ci.org/nshah/nodejs-walker.png)](http://travis-ci.org/nshah/nodejs-walker)
======
A nodejs directory walker. Broadcasts events for various file types as well as
View
62 test/walker.js
@@ -14,17 +14,25 @@ try {
} catch(e) {}
try { fs.mkdirSync(BAD_START_WALK, 0200) } catch(e) {}
-exports['simple walk'] = function(beforeExit) {
+function includes(list, item) {
+ for (var i=list.length-1; i > 0; i--) {
+ if (list[i] === item)
+ return true
+ }
+ return false
+}
+
+exports['simple walk'] = function(done) {
var n = 9
Walker(SIMPLE_WALK)
.on('dir', function(dir) {
- assert.includes([SIMPLE_WALK, SIMPLE_WALK + '/d'],
+ includes([SIMPLE_WALK, SIMPLE_WALK + '/d'],
dir, 'Unexpected directory.')
n--
})
.on('file', function(file) {
- assert.includes(
+ includes(
[SIMPLE_WALK + '/a',
SIMPLE_WALK + '/b',
SIMPLE_WALK + '/c',
@@ -39,14 +47,12 @@ exports['simple walk'] = function(beforeExit) {
})
.on('end', function() {
n--
+ assert.equal(0, n, 'Ensure expected asserts.')
+ done()
})
-
- beforeExit(function() {
- assert.equal(0, n, 'Ensure expected asserts.')
- })
}
-exports['simple walk, exclude sub-directory tree'] = function(beforeExit) {
+exports['simple walk, exclude sub-directory tree'] = function(done) {
var n = 5
Walker(SIMPLE_WALK)
@@ -58,7 +64,7 @@ exports['simple walk, exclude sub-directory tree'] = function(beforeExit) {
n--
})
.on('file', function(file) {
- assert.includes(
+ includes(
[SIMPLE_WALK + '/a',
SIMPLE_WALK + '/b',
SIMPLE_WALK + '/c'],
@@ -70,14 +76,12 @@ exports['simple walk, exclude sub-directory tree'] = function(beforeExit) {
})
.on('end', function() {
n--
+ assert.equal(0, n, 'Ensure expected asserts.')
+ done()
})
-
- beforeExit(function() {
- assert.equal(0, n, 'Ensure expected asserts.')
- })
}
-exports['error walk'] = function(beforeExit) {
+exports['error walk'] = function(done) {
var n = 6
Walker(ERROR_WALK)
@@ -86,7 +90,7 @@ exports['error walk'] = function(beforeExit) {
n--
})
.on('file', function(file) {
- assert.includes(
+ includes(
[ERROR_WALK + '/a',
ERROR_WALK + '/b',
ERROR_WALK + '/c'],
@@ -99,14 +103,12 @@ exports['error walk'] = function(beforeExit) {
})
.on('end', function() {
n--
+ assert.equal(0, n, 'Ensure expected asserts.')
+ done()
})
-
- beforeExit(function() {
- assert.equal(0, n, 'Ensure expected asserts.')
- })
}
-exports['bad start'] = function(beforeExit) {
+exports['bad start'] = function(done) {
var n = 2
Walker(BAD_START_WALK)
@@ -122,24 +124,22 @@ exports['bad start'] = function(beforeExit) {
})
.on('end', function() {
n--
+ assert.equal(0, n, 'Ensure expected asserts.')
+ done()
})
-
- beforeExit(function() {
- assert.equal(0, n, 'Ensure expected asserts.')
- })
}
-exports['symlink test'] = function(beforeExit) {
+exports['symlink test'] = function(done) {
var n = 10
Walker(SYMLINK_WALK)
.on('dir', function(dir) {
- assert.includes([SYMLINK_WALK, SYMLINK_WALK + '/d'],
+ includes([SYMLINK_WALK, SYMLINK_WALK + '/d'],
dir, 'Unexpected directory: ' + dir)
n--
})
.on('file', function(file) {
- assert.includes(
+ includes(
[
SYMLINK_WALK + '/a',
SYMLINK_WALK + '/b',
@@ -153,7 +153,7 @@ exports['symlink test'] = function(beforeExit) {
n--
})
.on('symlink', function(symlink) {
- assert.includes(
+ includes(
[
SYMLINK_WALK + '/c',
SYMLINK_WALK + '/e',
@@ -168,9 +168,7 @@ exports['symlink test'] = function(beforeExit) {
})
.on('end', function() {
n--
+ assert.equal(0, n, 'Ensure expected asserts: ' + n)
+ done()
})
-
- beforeExit(function() {
- assert.equal(0, n, 'Ensure expected asserts: ' + n)
- })
}
Please sign in to comment.
Something went wrong with that request. Please try again.