Sha256: 43025aa6e500d05ea75acef31ba56ee0caa43133c56c15e4f2feff07bbd34bcc

Contents?: true

Size: 1.78 KB

Versions: 41

Compression:

Stored size: 1.78 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            ©2008-2011 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================
// ========================================================================
// SC.Validator.CreditCard  Tests
// ========================================================================

module("credit_card validation - fieldValueForObject()");
test("Expects a string of 16 digits.  Will split into groups of 4 for display.",function(){
	var obj=SC.Validator.CreditCard.create();
	var string = "1234567890123456";
	var grouped_string = obj.fieldValueForObject("1234567891234567");
	equals(grouped_string,"1234 5678 9123 4567");	
});
test("Removes all whitespace or dashes to make a single string",function(){
	var obj=SC.Validator.CreditCard.create();
	var string = "1234 5678-9012-3456";
	var clean_string = obj.objectForFieldValue(string);
	equals(clean_string,"1234567890123456");	
});

test("Checks all valid card numbers or dashes to make a single string",function(){
	var obj=SC.Validator.CreditCard.create();
	var invalid_cc = "1234 5678-9012-3456";
	equals(obj.checkNumber(invalid_cc),false);
	var valid_cc = "4111 1111 1111 1111";
	equals(obj.checkNumber(valid_cc),true);	
});

// PROBLEM in function validateKeyDown 
// returns true instead of false and vice -versa
//test("Allow only numbers, dashes, and spaces",function(){
//	obj=SC.Validator.CreditCard.create();
//	string = "sdfk123";
//	equals(obj.validateKeyDown('','',string),false);
//	string = "123424";
//	equals(obj.validateKeyDown('','',string),true);
//});

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
sproutcore-1.11.0 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.11.0.rc3 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.11.0.rc2 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.11.0.rc1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.3.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.2 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.0 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.0.rc.3 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.0.rc.2 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.10.0.rc.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.9.2 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.9.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.9.0 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.8.2.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.8.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.8.0 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js