~singpolyma/sgx-jmp

sgx-jmp/test/test_customer_ogm.rb -rw-r--r-- 1.1 KiB
cd3111beStephen Paul Weber Merge branch 'snikket' 18 hours 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 "test_helper"
require "customer_ogm"

class CustomerOGMTest < Minitest::Test
	def test_for_url
		assert_kind_of(
			CustomerOGM::Media,
			CustomerOGM.for("https://example.com/test.mp3", -> {})
		)
	end

	def test_for_no_url
		assert_kind_of(
			CustomerOGM::TTS,
			CustomerOGM.for(nil, -> { EMPromise.resolve(nil) }).sync
		)
	end
	em :test_for_no_url

	class TTSTest < Minitest::Test
		def test_to_render_empty_vcard
			vcard = Blather::Stanza::Iq::Vcard::Vcard.new
			assert_equal(
				[:voicemail_ogm_tts, { locals: { fn: "a user of JMP.chat" } }],
				CustomerOGM::TTS.new(vcard).to_render
			)
		end

		def test_to_render_fn
			vcard = Blather::Stanza::Iq::Vcard::Vcard.new
			vcard["FN"] = "name"
			assert_equal(
				[:voicemail_ogm_tts, { locals: { fn: "name" } }],
				CustomerOGM::TTS.new(vcard).to_render
			)
		end

		def test_to_render_nickname
			vcard = Blather::Stanza::Iq::Vcard::Vcard.new
			vcard["NICKNAME"] = "name"
			assert_equal(
				[:voicemail_ogm_tts, { locals: { fn: "name" } }],
				CustomerOGM::TTS.new(vcard).to_render
			)
		end
	end
end