Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2016-11-28 14:01:25 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2016-11-28 14:01:44 -0500
commit6db99c8632e7e61f6e96404344f2d48b518e8878 (patch)
tree1803a5fdde144e1fd2cb72ace17ab4a762c13948 /test
parent14711cd4c63ed56d7411e5a968a35f97f302e786 (diff)
downloadliza-6db99c8632e7e61f6e96404344f2d48b518e8878.tar.gz
liza-6db99c8632e7e61f6e96404344f2d48b518e8878.tar.bz2
liza-6db99c8632e7e61f6e96404344f2d48b518e8878.zip
Add Currency formatter
* src/validate/formatter/Currency.js: Add trait. * test/validate/formatter/CurrencyTest.js: Add test case.
Diffstat (limited to 'test')
-rw-r--r--test/validate/formatter/CurrencyTest.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/validate/formatter/CurrencyTest.js b/test/validate/formatter/CurrencyTest.js
new file mode 100644
index 0000000..968e2e3
--- /dev/null
+++ b/test/validate/formatter/CurrencyTest.js
@@ -0,0 +1,60 @@
+/**
+ * Currency formatter test
+ *
+ * Copyright (C) 2016 LoVullo Associates, Inc.
+ *
+ * This file is part of liza.
+ *
+ * liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+var liza = require( '../../../' ),
+ Sut = liza.validate.formatter.Currency,
+ EchoFormatter = liza.validate.formatter.EchoFormatter,
+ common = require( './common' );
+
+
+describe( 'validate.formatter.Currency', function()
+{
+ common.testValidate( EchoFormatter.use( Sut )(), {
+ // should format anything given to it, with or without prefix
+ "1": [ "1", "$1" ],
+ "foo": [ "foo", "$foo" ],
+ "+": [ "+", "$+" ],
+ "$foo": [ "foo", "$foo" ],
+
+ // empty shouldn't format as anything
+ "": [ "", "" ],
+ "$": [ "", "" ],
+ "$$": [ "", "" ],
+
+ // make sure these aren't considered to be empty
+ "0": [ "0", "$0" ],
+ "$0": [ "0", "$0" ],
+
+ // be lax on input
+ "$$foo": [ "foo", "$foo" ],
+ "$$$$$$$12.34": [ "12.34", "$12.34" ],
+ } );
+
+
+ common.testMixin(
+ EchoFormatter,
+ Sut,
+ 'foo',
+ '123',
+ 'foo123',
+ '$foo123'
+ );
+} );