forked from asbjornu/drywall
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed test suite to use mocha for #10; WIP
Update the test suite to use Mocha. This tests results in creation of the model objects in /models. The ultimate goal is to create unit tests that are not dependent upon the actual database, in order to enforce separation. - package.json - Changed the npm test command to use a test runner named `test.js` which starts mocha with some configuration options set. Also added other packages to be used with testing, including: * lodash * factory-girl * factory-girl-sequelize * faker - test.js - Test runner starting Mocha with standard options. - specs/index-spec.js - Old supertest based test that no longer applies. - specs/models/AccountSpec.js - Unit test that checks the functionality of the Accont model. - models/Account.js - Changed the jshint to use 4 spaces.
- Loading branch information
Showing
5 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var chai = require('chai'); | ||
var expect = chai.expect; | ||
var _ = require('lodash'); | ||
var sinon = require('sinon'); | ||
var faker = require('faker'); | ||
var factory = require('factory-girl'); | ||
var models = require(process.cwd() + '/models/index'); | ||
|
||
|
||
describe('Models/Account', function () { | ||
beforeEach(function (done) { | ||
AccountModel = models.Account; | ||
done(); | ||
}); | ||
|
||
afterEach(function (done) { | ||
AccountModel = models.Account; | ||
done(); | ||
}); | ||
|
||
describe('account', function () { | ||
it('should be true', function () { | ||
expect(models.Account).to.be.an('object'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var _ = require('lodash'); | ||
var Mocha = require('mocha'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var testConfig = { | ||
NODE_ENV: 'test' | ||
}; | ||
|
||
_.each(testConfig, function(value, key){ | ||
process.env[key] = value; | ||
}); | ||
|
||
var mocha = new Mocha({ | ||
timeout: 60000, | ||
reporter: "spec" | ||
}); | ||
|
||
["specs/models"].forEach(function(pathName){ | ||
// Here is an example: | ||
fs.readdirSync(pathName).filter(function(file){ | ||
// Only keep the .js files | ||
return file.substr(-3) === '.js'; | ||
|
||
}).forEach(function(file){ | ||
mocha.addFile( | ||
path.join(pathName, file) | ||
); | ||
}); | ||
}); | ||
|
||
mocha.run(function(failures){ | ||
process.on('exit', function () { | ||
process.exit(failures); | ||
}); | ||
|
||
process.exit(0); | ||
}); |