test(disco-info): gateway returns gateway identity

Phillip Davis created

Change summary

test/property/test_disco_info.rb | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

Detailed changes

test/property/test_disco_info.rb 🔗

@@ -40,4 +40,32 @@ class DiscoInfoPropertyTest < Minitest::Test
 		}
 	end
 	em :test_disco_info_get_for_user_returns_user_caps
+
+	def test_disco_info_get_for_gateway_returns_gateway_identity
+		property_of {
+			DiscoInfoIQ
+				.new(REDIS)
+				.target_node { nil }
+				.generate
+		}.check { |_metadata, example|
+			process_stanza(example['stanza'])
+
+			assert_equal 1, written.length
+			reply = written.shift
+
+			assert_equal example['jid'], reply.to.to_s
+
+			ns = 'http://jabber.org/protocol/disco#info'
+			ids = reply.query.find('.//ns:identity', ns: ns)
+			gateway_id = ids.find { |i| i[:category] == 'gateway' }
+			assert gateway_id, 'Should include gateway identity'
+			assert_equal 'sms', gateway_id[:type]
+
+			feats = reply.query.find('.//ns:feature', ns: ns).map { |f| f[:var] }
+			assert_includes feats, 'http://jabber.org/protocol/disco#info'
+			assert_includes feats, 'jabber:iq:register'
+			assert_includes feats, 'http://jabber.org/protocol/commands'
+		}
+	end
+	em :test_disco_info_get_for_gateway_returns_gateway_identity
 end