~singpolyma/sgx-jmp

ref: 2f7a1b60192a14c86ef9a1f727ea9369cfedc2c6 sgx-jmp/test/test_oob.rb -rw-r--r-- 1.1 KiB
2f7a1b60Stephen Paul Weber Merge branch 'more-tel-selection-coverage' 11 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
43
44
45
46
47
48
49
# frozen_string_literal: true

require "oob"

class OOBTest < Minitest::Test
	def test_new
		oob = OOB.new
		assert_kind_of OOB, oob
		assert_nil oob.url
		assert_nil oob.desc
	end

	def test_new_with_node
		assert_kind_of OOB, OOB.new(Blather::XMPPNode.new)
	end

	property(:new_with_attrs) { [string(:alnum), string] }
	def new_with_attrs(url, description)
		oob = OOB.new(url, desc: description)
		assert_kind_of OOB, oob
		assert_equal url, oob.url
		assert_equal description, oob.desc
	end

	def test_find_or_create_not_found
		assert_kind_of OOB, OOB.find_or_create(Blather::XMPPNode.new)
	end

	def test_find_or_create_found
		parent = Blather::XMPPNode.new
		parent << OOB.new("http://example.com")
		assert_kind_of OOB, OOB.find_or_create(parent)
		assert_equal "http://example.com", OOB.find_or_create(parent).url
	end

	property(:url) { string(:alnum) }
	def url(a_url)
		oob = OOB.new
		oob.url = a_url
		assert_equal a_url, oob.url
	end

	property(:desc) { string }
	def desc(description)
		oob = OOB.new
		oob.desc = description
		assert_equal description, oob.desc
	end
end