Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Added one test per UI

Tj Holowaychuk018299e0e8d1
diff --git a/Makefile b/Makefile
index 603b2bb0..44c43b63 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,28 @@
-TESTS = test/*.js
+TESTS = test/unit/*.js
REPORTER = list
-test:
+test: test-bdd test-tdd test-exports
+
+test-bdd:
@./bin/mocha \
--require should \
--reporter $(REPORTER) \
--ui bdd \
- $(TESTS)
+ test/bdd.js
+
+test-tdd:
+ @./bin/mocha \
+ --require should \
+ --reporter $(REPORTER) \
+ --ui tdd \
+ test/tdd.js
+
+test-exports:
+ @./bin/mocha \
+ --require should \
+ --reporter $(REPORTER) \
+ --ui exports \
+ test/exports.js
-.PHONY: test
\ No newline at end of file
+.PHONY: test test-bdd test-tdd test-exports
\ No newline at end of file
diff --git a/test/basic.js b/test/bdd.js
similarity index 100%
rename from test/basic.js
rename to test/bdd.js
diff --git a/test/exports.js b/test/exports.js
new file mode 100644
index 00000000..eb15f2ad
--- /dev/null
+++ b/test/exports.js
@@ -0,0 +1,15 @@
+
+exports.Array = {
+ '#indexOf()': {
+ '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);
+ },
+
+ '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);
+ }
+ }
+};
diff --git a/test/tdd.js b/test/tdd.js
new file mode 100644
index 00000000..c6f23080
--- /dev/null
+++ b/test/tdd.js
@@ -0,0 +1,15 @@
+
+suite('Array', function(){
+ suite('#indexOf()', function(){
+ test('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);
+ })
+
+ test('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);
+ })
+ })
+})
diff --git a/test/unit/basic.js b/test/unit/basic.js
new file mode 100644
index 00000000..80f9817f
--- /dev/null
+++ b/test/unit/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);
+ })
+ })
+})