~singpolyma/sgx-jmp

ref: 023c87a11bbaa6bd3eaeb3977330b8ea80ded0cd sgx-jmp/test/test_cdr.rb -rw-r--r-- 1.1 KiB
023c87a1Stephen Paul Weber Quieter voicemail beep 8 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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