Skip to content

Commit

Permalink
Redundant method removed from scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwaliszko committed Nov 24, 2014
1 parent d7abb8f commit 1903eca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
14 changes: 4 additions & 10 deletions src/expressive.annotations.validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ var
}
}
return false;
},
sanatize: function(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
}
}
}
},
object: {
Expand Down Expand Up @@ -404,7 +396,7 @@ var

annotations = ' abcdefghijklmnopqrstuvwxyz'; // suffixes for attributes annotating single field multiple times

$.each(annotations.split(''), function() { // should be optimized in terms of memory consumption (redundant handlers shouldn't be generated, it would be ideal to have exactly as many handlers as there are unique annotations)
$.each(annotations.split(''), function() { // it would be ideal to have exactly as many handlers as there are unique annotations, but the number of annotations isn't known untill DOM is ready
var adapter = 'assertthat' + $.trim(this);
$.validator.unobtrusive.adapters.add(adapter, ['expression', 'fieldsmap', 'constsmap'], function(options) {
options.rules[adapter] = {
Expand Down Expand Up @@ -478,11 +470,13 @@ var
}, '');
});

api.___6BE7863DC1DB4AFAA61BB53FF97FE169 = { // for testing
// for testing only (section to be removed in release code)
api.___6BE7863DC1DB4AFAA61BB53FF97FE169 = {
typeHelper: typeHelper,
modelHelper: modelHelper,
toolchain: toolchain
};
// --------------------------------------------------------

window.ea = api; // expose some tiny api to the ea global object

Expand Down
22 changes: 2 additions & 20 deletions src/expressive.annotations.validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@
window.ok(!ea.typeHelper.array.contains(["a", "b"], "c"));
});

test("verify_array_sanatization", function() {
var array = ["a"];
ea.typeHelper.array.sanatize(["a"], "");
window.deepEqual(array, ["a"]);

array = ["a", "a"];
ea.typeHelper.array.sanatize(array, "a");
window.deepEqual(array, []);

array = ["a", "b"];
ea.typeHelper.array.sanatize(array, "");
window.deepEqual(array, ["a", "b"]);

array = ["a", "b", "c", "a", "b"];
ea.typeHelper.array.sanatize(array, "b");
window.deepEqual(array, ["a", "c", "a"]);
});

test("verify_object_keys_extraction", function() {
var assocArray = [];
assocArray["one"] = "lorem";
Expand Down Expand Up @@ -88,8 +70,8 @@
actual = ea.typeHelper.tryParse("11/08/2014", "datetime");
window.ok(actual == expected);

window.ea.settings.parseDate = function(str) { // simulate broken parsing logic
return NaN;
window.ea.settings.parseDate = function(str) {
return NaN; // simulate broken parsing logic
};
var result = ea.typeHelper.tryParse("11/08/2014", "datetime");
window.equal(result.error, true);
Expand Down

0 comments on commit 1903eca

Please sign in to comment.