2020-07-06 15:03:28 +00:00
|
|
|
test( "ticket macro pending time check", function() {
|
2020-10-22 12:52:26 +00:00
|
|
|
var test_relative = function(rules, target, description, offset){
|
2020-07-06 15:03:28 +00:00
|
|
|
var ticket = new App.Ticket()
|
|
|
|
|
|
|
|
App.Ticket.macro({
|
|
|
|
ticket: ticket,
|
|
|
|
macro: {
|
|
|
|
"ticket.pending_time": rules
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var compare_against = new Date()
|
|
|
|
var travel = Math.abs( new Date(ticket.pending_time) - compare_against)
|
|
|
|
|
2020-10-22 12:52:26 +00:00
|
|
|
var diff = Math.abs(target - travel) - offset*1000
|
2020-07-06 15:03:28 +00:00
|
|
|
|
|
|
|
ok(diff < 1000, description)
|
|
|
|
}
|
|
|
|
|
2020-10-22 12:52:26 +00:00
|
|
|
var data = document.getElementsByTagName('data')[0].dataset
|
|
|
|
debugger
|
|
|
|
|
2020-07-06 15:03:28 +00:00
|
|
|
var rules = {
|
|
|
|
operator: "relative",
|
|
|
|
range: "day",
|
|
|
|
value: 5
|
|
|
|
}
|
|
|
|
|
2020-10-22 12:52:26 +00:00
|
|
|
test_relative(rules, 60 * 60 * 24 * 5 * 1000, '5 days', data['offset-5Days'])
|
2020-07-06 15:03:28 +00:00
|
|
|
|
|
|
|
var rules = {
|
|
|
|
operator: "relative",
|
|
|
|
range: "minute",
|
|
|
|
value: 3
|
|
|
|
}
|
|
|
|
|
2020-10-22 12:52:26 +00:00
|
|
|
test_relative(rules, 60 * 3 * 1000, '5 minutes', data['offset-3Minutes'])
|
2020-07-06 15:03:28 +00:00
|
|
|
|
|
|
|
var rules = {
|
|
|
|
operator: "relative",
|
|
|
|
range: "hour",
|
|
|
|
value: 10
|
|
|
|
}
|
|
|
|
|
2020-10-22 12:52:26 +00:00
|
|
|
test_relative(rules, 60 * 60 * 10 * 1000, '10 hours', data['offset-10Hours'])
|
2020-07-06 15:03:28 +00:00
|
|
|
})
|