-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aaron Held
authored and
Aaron Held
committed
Feb 15, 2018
1 parent
306d622
commit b13b0a6
Showing
6 changed files
with
106 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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,3 @@ | ||
module.exports.add = function(input){ | ||
return 0; | ||
} |
Binary file not shown.
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,29 @@ | ||
{ | ||
"name": "calc", | ||
"version": "1.0.0", | ||
"description": "setup for the calculator kata", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha", | ||
"testw": "mocha -w" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/aheld/code-kata.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/aheld/code-kata/issues" | ||
}, | ||
"homepage": "https://github.com/aheld/code-kata#readme", | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"mocha": "^5.0.1" | ||
}, | ||
"dependencies": { | ||
"eslint": "^4.17.0", | ||
"sequelize": "^4.33.4", | ||
"sqlite3": "^3.1.13" | ||
} | ||
} |
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,12 @@ | ||
var should = require('chai').should(); | ||
var assert = require('chai').assert; | ||
|
||
var calc = require('./calculator.js'); | ||
|
||
describe('Calculator', function() { | ||
describe('#add', function() { | ||
it('should return -1 when the value is not present', function() { | ||
calc.add('').should.equal(0); | ||
}); | ||
}); | ||
}); |
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,61 @@ | ||
const Sequelize = require('sequelize'); | ||
const sequelize = new Sequelize('database', 'username', 'password', { | ||
host: 'localhost', | ||
dialect: 'sqlite', | ||
|
||
pool: { | ||
max: 5, | ||
min: 0, | ||
acquire: 30000, | ||
idle: 10000 | ||
}, | ||
|
||
// SQLite only | ||
storage: './database.sqlite' | ||
}); | ||
|
||
const User = sequelize.define('user', { | ||
firstName: { | ||
type: Sequelize.STRING | ||
}, | ||
lastName: { | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
defaultValue: '', | ||
validate: {len: [2,50] } } | ||
}); | ||
|
||
|
||
|
||
var should = require('chai').should(); | ||
|
||
describe('User', function() { | ||
describe('#create', function() { | ||
it('should validate if valid', function(done) { | ||
User.sync({force: true}).then(() => { | ||
User.create({ | ||
firstName: 'John', | ||
lastName: 'Hancock' | ||
}); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should throw a validation error if not valid', function(done) { | ||
User.sync({force: true}).then(() => { | ||
User.create({ | ||
firstName: 'John', | ||
lastName: '' | ||
}).then(function(x) { | ||
x.should.be.a('Error'); | ||
done(); | ||
}).catch( function (e) { | ||
e.should.be.a('Error'); | ||
done(); | ||
}); | ||
|
||
}); | ||
}); | ||
|
||
}); | ||
}); |