Sha256: 3cf53f1bebb4a96be6a40be5cc72e5e34730caff1192aca86102ba989396625b

Contents?: true

Size: 1.84 KB

Versions: 41

Compression:

Stored size: 1.84 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Apple Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*global module test equals context ok same */
var notEmptyValidator, field;

module("SC.Validator.NotEmpty", {
    setup: function () {
        notEmptyValidator = SC.Validator.NotEmpty.create();
        field = SC.Object.create();
    },
    teardown: function () {
        notEmptyValidator.destroy();
        notEmptyValidator = null;
    }
});

test("Recognizes a non-empty string as valid",function(){
    field.set('fieldValue', "fnord");
    var isValid = notEmptyValidator.validate(undefined, field);
    ok(isValid, "Not empty string is valid");
});

test("Recognizes empty string as invalid",function(){
    field.set('fieldValue', "");
    var isValid = notEmptyValidator.validate(undefined, field);
    ok( ! isValid, "Empty string is not valid");
});

test("Recognizes null as empty",function(){
    field.set('fieldValue', null);
    var isValid = notEmptyValidator.validate(undefined, field);
    ok( ! isValid, "null string is not valid");
});

test("Recognizes undefined as empty",function(){
    field.set('fieldValue', undefined);
    var isValid = notEmptyValidator.validate(undefined, field);
    ok( ! isValid, "null string is not valid");
});

test("Recognizes some number as non-empty",function(){
    field.set('fieldValue', 42);
    var isValid = notEmptyValidator.validate(undefined, field);
    ok(isValid, "42 string is not empty");
});

test("Recognizes zero as non-empty",function(){
    field.set('fieldValue', 0);
    var isValid = notEmptyValidator.validate(undefined, field);
    ok(isValid, "0 string is not empty");
});

Version data entries

41 entries across 41 versions & 1 rubygems

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