From 9f063c13c52e28681a8d0b0c894f6b435b486f69 Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Wed, 27 Mar 2013 04:37:13 +0400 Subject: [PATCH] Moved to mocha --- Makefile | 14 ++++++++++++++ package.json | 13 ++++++++++--- test/init.js | 12 ++++++++++++ test/mysql.js | 28 ---------------------------- test/mysql.test.js | 23 +++++++++++++++++++++++ 5 files changed, 59 insertions(+), 31 deletions(-) create mode 100644 Makefile create mode 100644 test/init.js delete mode 100644 test/mysql.js create mode 100644 test/mysql.test.js diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1bbe15b --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +## TESTS + +TESTER = ./node_modules/.bin/mocha +OPTS = --require ./test/init.js +TESTS = test/*.test.js + +test: + $(TESTER) $(OPTS) $(TESTS) +test-verbose: + $(TESTER) $(OPTS) --reporter spec $(TESTS) +testing: + $(TESTER) $(OPTS) --watch $(TESTS) + +.PHONY: test docs diff --git a/package.json b/package.json index 3391b86..472c124 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ }, "devDependencies": { "coffee-script": "latest", - "nodeunit": "latest" + "should": "~1.2.2", + "mocha": "~1.8.2" }, "repository": { "type": "git", @@ -20,8 +21,14 @@ }, "author": "Anatoliy Chakkaev ", "maintainers": [ - { "name": "dgsan", "url": "https://github.com/dgsan" }, - { "name": "Anatoliy Chakkaev", "url": "https://github.com/1602" } + { + "name": "dgsan", + "url": "https://github.com/dgsan" + }, + { + "name": "Anatoliy Chakkaev", + "url": "https://github.com/1602" + } ], "license": "MIT" } diff --git a/test/init.js b/test/init.js new file mode 100644 index 0000000..81546b4 --- /dev/null +++ b/test/init.js @@ -0,0 +1,12 @@ +var Schema = require('jugglingdb').Schema; + +global.getSchema = function() { + var db = new Schema(require('../'), { + database: 'myapp_test', + username: 'root' + }); + db.log = function (a) { + console.log(a); + }; + return db; +}; diff --git a/test/mysql.js b/test/mysql.js deleted file mode 100644 index 654eabe..0000000 --- a/test/mysql.js +++ /dev/null @@ -1,28 +0,0 @@ -var jdb = require('jugglingdb'), - Schema = jdb.Schema, - test = jdb.test, - schema = new Schema(__dirname + '/..', { - database: 'myapp_test', - username: 'root' - }); - -test(module.exports, schema); - -var Post, User; - -test.it('hasMany should support additional conditions', function (test) { - - Post = schema.models.Post; - User = schema.models.User; - - User.create(function (e, u) { - u.posts.create({}, function (e, p) { - u.posts({where: {id: p.id}}, function (e, posts) { - test.equal(posts.length, 1, 'There should be only 1 post.'); - test.done(); - }); - }); - }); - -}); - diff --git a/test/mysql.test.js b/test/mysql.test.js new file mode 100644 index 0000000..780be48 --- /dev/null +++ b/test/mysql.test.js @@ -0,0 +1,23 @@ +var db, Model, should = require('should'); + +require('jugglingdb/test/common.batch.js'); +require('jugglingdb/test/include.test.js'); + +var Post, User; + +// test.it('hasMany should support additional conditions', function (test) { +// +// Post = schema.models.Post; +// User = schema.models.User; +// +// User.create(function (e, u) { +// u.posts.create({}, function (e, p) { +// u.posts({where: {id: p.id}}, function (e, posts) { +// test.equal(posts.length, 1, 'There should be only 1 post.'); +// test.done(); +// }); +// }); +// }); +// +// }); +