Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

added example test

Tj Holowaychuk79db963ba744
diff --git a/Makefile b/Makefile
index c924e9fe..f5c5d188 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ TESTS = test/*.js
test:
@./bin/mocha \
--require should \
- --reporter spec \
+ --reporter list \
--ui bdd \
$(TESTS)
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index 821e92a9..6b54d453 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -175,7 +175,7 @@ Base.prototype.epilogue = function(){
console.log(
color('fail message', ' ✖ %d of %d tests failed')
, stats.failures, stats.tests);
- Base.list(self.failures);
+ Base.list(this.failures);
console.log();
process.exit(stats.failures);
}
diff --git a/test/basic.js b/test/basic.js
index e69de29b..80f9817f 100644
--- a/test/basic.js
+++ b/test/basic.js
@@ -0,0 +1,15 @@
+
+describe('Array', function(){
+ describe('#indexOf()', function(){
+ it('should return -1 when the value is not present', function(){
+ [1,2,3].indexOf(5).should.equal(-1);
+ [1,2,3].indexOf(0).should.equal(-1);
+ })
+
+ it('should return the correct index when the value is present', function(){
+ [1,2,3].indexOf(1).should.equal(0);
+ [1,2,3].indexOf(2).should.equal(1);
+ [1,2,3].indexOf(3).should.equal(2);
+ })
+ })
+})