Skip to content
Browse files

Add test for monetary formatting (USD)

  • Loading branch information...
1 parent 164c5a8 commit cf73756e44e8b677585fe8542a9b8308ccb85e9c @jugglinmike jugglinmike committed Aug 22, 2012
Showing with 21 additions and 0 deletions.
  1. +3 −0 app/regex.js
  2. +18 −0 tests/app/regex.js
View
3 app/regex.js
@@ -20,6 +20,9 @@ define(function() {
matchesPattern : function(str) {
+ },
+ isUSD : function(str) {
+
}
};
});
View
18 tests/app/regex.js
@@ -38,5 +38,23 @@ define([
expect(answers.matchesPattern('800-555-12121')).to.be(false);
});
+ it("you should be able to detect correctly-formatted monetary amounts in USD", function() {
+ expect(answers.isUSD('$132.03')).to.be(true);
+ expect(answers.isUSD('$32.03')).to.be(true);
+ expect(answers.isUSD('$2.03')).to.be(true);
+ expect(answers.isUSD('$1,023,032.03')).to.be(true);
+ expect(answers.isUSD('$20,933,209.93')).to.be(true);
+ expect(answers.isUSD('$20,933,209')).to.be(true);
+ expect(answers.isUSD('$459,049,393.21')).to.be(true);
+ expect(answers.isUSD('34,344.34')).to.be(false);
+ expect(answers.isUSD('$,344.34')).to.be(false);
+ expect(answers.isUSD('$34,344.3')).to.be(false);
+ expect(answers.isUSD('$34,344.344')).to.be(false);
+ expect(answers.isUSD('$34,344_34')).to.be(false);
+ expect(answers.isUSD('$3,432,12.12')).to.be(false);
+ expect(answers.isUSD('$3,432,1,034.12')).to.be(false);
+ expect(answers.isUSD('4$3,432,034.12')).to.be(false);
+ });
+
});
});

0 comments on commit cf73756

Please sign in to comment.
Something went wrong with that request. Please try again.