~singpolyma/sgx-jmp

ref: 9300f0d14c86a191fbf94b2536a5c3fb31ca4a7f sgx-jmp/test/test_bandwidth_tn_order.rb -rw-r--r-- 1.9 KiB
9300f0d1Stephen Paul Weber Helper to allow ordering phone number from Bandwidth v2 1 year, 1 month 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# frozen_string_literal: true

require "test_helper"
require "bandwidth_tn_order"

class BandwidthTNOrderTest < Minitest::Test
	def test_for_received
		order = BandwidthTNOrder.for(BandwidthIris::Order.new(
			order_status: "RECEIVED"
		))
		assert_kind_of BandwidthTNOrder::Received, order
	end

	def test_for_complete
		order = BandwidthTNOrder.for(BandwidthIris::Order.new(
			order_status: "COMPLETE"
		))
		assert_kind_of BandwidthTNOrder::Complete, order
	end

	def test_for_failed
		order = BandwidthTNOrder.for(BandwidthIris::Order.new(
			order_status: "FAILED"
		))
		assert_kind_of BandwidthTNOrder::Failed, order
	end

	def test_for_unknown
		order = BandwidthTNOrder.for(BandwidthIris::Order.new(
			order_status: "randOmgarBagE"
		))
		assert_kind_of BandwidthTNOrder, order
		assert_equal :randomgarbage, order.status
	end

	def test_poll
		order = BandwidthTNOrder.new(BandwidthIris::Order.new)
		assert_raises { order.poll.sync }
	end
	em :test_poll

	class TestReceived < Minitest::Test
		BandwidthTNOrder::Received::BandwidthTNOrder = Minitest::Mock.new

		def setup
			@order = BandwidthTNOrder::Received.new(
				BandwidthIris::Order.new(id: "oid")
			)
		end

		def test_poll
			new_order = PromiseMock.new
			new_order.expect(:poll, nil)
			BandwidthTNOrder::Received::BandwidthTNOrder.expect(
				:get,
				new_order,
				["oid"]
			)
			@order.poll.sync
			BandwidthTNOrder::Received::BandwidthTNOrder.verify
		end
		em :test_poll
	end

	class TestComplete < Minitest::Test
		def setup
			@order = BandwidthTNOrder::Complete.new(BandwidthIris::Order.new)
		end

		def test_poll
			assert_equal @order, @order.poll.sync
		end
		em :test_poll
	end

	class TestFailed < Minitest::Test
		def setup
			@order = BandwidthTNOrder::Failed.new(
				BandwidthIris::Order.new(id: "oid")
			)
		end

		def test_poll
			assert_raises { @order.poll.sync }
		end
		em :test_poll
	end
end