~singpolyma/sgx-jmp

ref: 6665370def4be4097eda0de37d29c288954936ed sgx-jmp/test/test_cdr.rb -rw-r--r-- 1.1 KiB
6665370dStephen Paul Weber No low balance if not registered 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