Skip to content

Commit

Permalink
removed node 0.8 from travis, bumped version and additional methids
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkalosi committed Apr 2, 2015
1 parent 2fc35f4 commit d4dfafa
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: "node_js"
node_js:
- "0.12"
- "0.11"
- "0.10"
- "0.8"

before_install:
- "npm install istanbul -g"
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-money",
"description": "JavaScript implementation of the Money value object.",
"version": "0.1.0",
"version": "0.2.0",
"main": "./lib",
"author": {
"name": "David Kalosi",
Expand All @@ -25,4 +25,4 @@
"mocha": "1.x.x",
"chai": "1.x.x"
}
}
}
27 changes: 27 additions & 0 deletions lib/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,32 @@ Money.prototype.compare = function(other) {
return self.amount > other.amount ? 1 : -1;
};

/**
* Returns true if the amount is zero.
*
* @returns {boolean}
*/
Money.prototype.isZero = function() {
return this.amount === 0;
};

/**
* Returns true if the amount is positive.
*
* @returns {boolean}
*/
Money.prototype.isPositive = function() {
return this.amount > 0;
};

/**
* Returns true if the amount is negative.
*
* @returns {boolean}
*/
Money.prototype.isNegative = function() {
return this.amount < 0;
};

module.exports = Money;
module.exports = _.extend(module.exports, currencies);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "js-money",
"description": "JavaScript implementation of the Money value object.",
"version": "0.1.0",
"version": "0.2.0",
"main": "./lib",
"author": {
"name": "David Kalosi",
Expand Down
25 changes: 24 additions & 1 deletion test/money.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,29 @@ describe('Money', function () {
expect(results[2].amount).to.equal(333);
expect(results[2].currency).to.equal('EUR');
});


it('zero check works correctly', function() {
var subject = new Money(1000, 'EUR');
var subject1 = new Money(0, 'EUR');

expect(subject.isZero()).to.be.false;
expect(subject1.isZero()).to.be.true;
});

it('positive check works correctly', function() {
var subject = new Money(1000, 'EUR');
var subject1 = new Money(-1000, 'EUR');

expect(subject.isPositive()).to.be.true;
expect(subject1.isPositive()).to.be.false;
});

it('negative check works correctly', function() {
var subject = new Money(1000, 'EUR');
var subject1 = new Money(-1000, 'EUR');

expect(subject.isNegative()).to.be.false;
expect(subject1.isNegative()).to.be.true;
});

});

0 comments on commit d4dfafa

Please sign in to comment.