1# frozen_string_literal: true
 2
 3require "oob"
 4
 5class OOBTest < Minitest::Test
 6	def test_new
 7		oob = OOB.new
 8		assert_kind_of OOB, oob
 9		assert_nil oob.url
10		assert_nil oob.desc
11	end
12
13	def test_new_with_node
14		assert_kind_of OOB, OOB.new(Blather::XMPPNode.new)
15	end
16
17	property(:new_with_attrs) { [string(:alnum), string] }
18	def new_with_attrs(url, description)
19		oob = OOB.new(url, desc: description)
20		assert_kind_of OOB, oob
21		assert_equal url, oob.url
22		assert_equal description, oob.desc
23	end
24
25	def test_find_or_create_not_found
26		assert_kind_of OOB, OOB.find_or_create(Blather::XMPPNode.new)
27	end
28
29	def test_find_or_create_found
30		parent = Blather::XMPPNode.new
31		parent << OOB.new("http://example.com")
32		assert_kind_of OOB, OOB.find_or_create(parent)
33		assert_equal "http://example.com", OOB.find_or_create(parent).url
34	end
35
36	property(:url) { string(:alnum) }
37	def url(a_url)
38		oob = OOB.new
39		oob.url = a_url
40		assert_equal a_url, oob.url
41	end
42
43	property(:desc) { string }
44	def desc(description)
45		oob = OOB.new
46		oob.desc = description
47		assert_equal description, oob.desc
48	end
49end