Methods: Add additional method for currency

Closes gh-701
This commit is contained in:
James Thompson
2014-01-14 19:18:19 +01:00
committed by Jörn Zaefferer
parent a86421131e
commit 1a981b4403
2 changed files with 65 additions and 0 deletions

View File

@@ -1166,4 +1166,28 @@ test("rangeWords", function(){
ok(!method( "<div>But you can “count” me as too long</div>", rangeWords), "Too many words with smartquotes w/ HTML");
});
test("currency", function() { // Works with any symbol
var method = methodTest( "currency" );
ok( method( "£9", '£'), "Valid currency" );
ok( method( "£9.9", '£'), "Valid currency" );
ok( method( "£9.99", '£'), "Valid currency" );
ok( method( "£9.90", '£'), "Valid currency" );
ok( method( "£9,999.9", '£'), "Valid currency" );
ok( method( "£9,999.99", '£'), "Valid currency" );
ok( method( "£9,999,999.9", '£'), "Valid currency" );
ok( method( "9", ['£', false]), "Valid currency" );
ok( method( "9.9", ['£', false]), "Valid currency" );
ok( method( "9.99", ['£', false]), "Valid currency" );
ok( method( "9.90", ['£', false]), "Valid currency" );
ok( method( "9,999.9", ['£', false]), "Valid currency" );
ok( method( "9,999.99", ['£', false]), "Valid currency" );
ok( method( "9,999,999.9", ['£', false]), "Valid currency" );
ok(!method( "9,", '£'), "Invalid currency" );
ok(!method( "9,99.99", '£'), "Invalid currency" );
ok(!method( "9,", '£'), "Invalid currency" );
ok(!method( "9.999", '£'), "Invalid currency" );
ok(!method( "9.999", '£'), "Invalid currency" );
ok(!method( "9.99,9", '£'), "Invalid currency" );
});
})(jQuery);