Commit 9ac7d07b authored by Tejesh's avatar Tejesh 🖖
Browse files

fix tests for ~ and !~ operators

parent fa1486eb
Pipeline #52749 passed with stage
in 3 minutes and 3 seconds
......@@ -23,7 +23,6 @@ var operators = {
return greater_than(value, compare_with, false)
},
'<': function (value, compare_with) {
// console.log(value, compare_with)
return greater_than(compare_with, value, false)
},
'>~': function (value, compare_with) {
......@@ -33,10 +32,10 @@ var operators = {
return greater_than(compare_with, value, true)
},
'~': function (value, compare_with) {
return isEqual(compare_with, value, false)
return compare_with.indexOf(value) >= 0 ? true : false
},
'!~': function (value, compare_with) {
return isEqual(compare_with, value, true)
return compare_with.indexOf(value) >= 0 ? false : true
}
}
......
......@@ -192,11 +192,11 @@ test('g1.datafilter test', function(t) {
var result = g1.datafilter(continent_data, { "Name~": ["United"] })
var length_of_valid_data = 0
for (var row in continent_data) {
if (continent_data[row]["Name"] == "United") length_of_valid_data++
if (continent_data[row]["Name"].indexOf("United") != -1) length_of_valid_data++
}
t.equals(result.length, length_of_valid_data)
t.ok(result.every(function (val) {
return (val["Name"] == "United")
return (val["Name"].indexOf("United") != -1)
}))
t.end()
})
......@@ -205,11 +205,11 @@ test('g1.datafilter test', function(t) {
var result = g1.datafilter(continent_data, { "Name!~": ["United"] })
var length_of_valid_data = 0
for (var row in continent_data) {
if (continent_data[row]["Name"] != "United") length_of_valid_data++
if (continent_data[row]["Name"].indexOf("United") == -1) length_of_valid_data++
}
t.equals(result.length, length_of_valid_data)
t.ok(result.every(function (val) {
return val["Name"] != "United"
return (val["Name"].indexOf("United") == -1)
}))
t.end()
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment