# frozen_string_literal: true
require "test_helper"
require "cdr"
class CDRTest < Minitest::Test
def test_for_inbound
cdr = CDR.for_inbound(
"test",
"from" => "+15551234567",
"startTime" => "2020-01-01T00:00:00Z",
"endTime" => "2020-01-01T01:00:00Z",
"callId" => "a_call",
"cause" => "hangup"
)
assert_equal cdr.cdr_id, "sgx-jmp/a_call"
assert_equal cdr.customer_id, "test"
assert_equal cdr.start, Time.parse("2020-01-01T00:00:00Z")
assert_equal cdr.billsec, 60 * 60
assert_equal cdr.disposition, "ANSWERED"
assert_equal cdr.tel, "+15551234567"
assert_equal cdr.direction, :inbound
end
def test_for_outbound
cdr = CDR.for_outbound(
"to" => "+15551234567",
"from" => "+test",
"startTime" => "2020-01-01T00:00:00Z",
"endTime" => "2020-01-01T01:00:00Z",
"callId" => "a_call",
"cause" => "hangup"
)
assert_equal cdr.cdr_id, "sgx-jmp/a_call"
assert_equal cdr.customer_id, "test"
assert_equal cdr.start, Time.parse("2020-01-01T00:00:00Z")
assert_equal cdr.billsec, 60 * 60
assert_equal cdr.disposition, "ANSWERED"
assert_equal cdr.tel, "+15551234567"
assert_equal cdr.direction, :outbound
end
end