billing: Use underscore built in contains function.

This commit is contained in:
Vishnu Ks 2019-01-07 16:39:14 +05:30 committed by showell
parent 37c78abe14
commit b89a10676a
2 changed files with 1 additions and 11 deletions

View File

@ -2,9 +2,3 @@ set_global('$', global.make_zjquery());
set_global('page_params', {});
zrequire('helpers', "js/billing/helpers");
run_test("is_in_array", () => {
var good_houses_array = ["Gryffindor", "Hufflepuff", "Ravenclaw"];
assert.equal(helpers.is_in_array("Hufflepuff", good_houses_array), true);
assert.equal(helpers.is_in_array("Slytherin", good_houses_array), false);
});

View File

@ -1,10 +1,6 @@
var helpers = (function () {
var exports = {};
exports.is_in_array = function (value, array) {
return array.indexOf(value) > -1;
};
exports.create_ajax_request = function (url, form_name, stripe_token = null) {
var form = $("#" + form_name + "-form");
var form_loading_indicator = "#" + form_name + "_loading_indicator";
@ -27,7 +23,7 @@ exports.create_ajax_request = function (url, form_name, stripe_token = null) {
}
form.serializeArray().forEach(function (item) {
if (exports.is_in_array(item.name, numeric_inputs)) {
if (_.contains(numeric_inputs, item.name)) {
data[item.name] = item.value;
} else {
data[item.name] = JSON.stringify(item.value);