# frozen_string_literal: true
require "test_helper"
API::REDIS = Minitest::Mock.new
class CustomerInfoTest < Minitest::Test
def test_info_does_not_crash
sgx = Minitest::Mock.new
sgx.expect(:registered?, EMPromise.resolve(nil))
cust = customer(sgx: sgx)
assert cust.info.sync.fields
assert_mock sgx
end
em :test_info_does_not_crash
def test_admin_info_does_not_crash
sgx = Minitest::Mock.new
sgx.expect(:registered?, EMPromise.resolve(nil))
API::REDIS.expect(
:exists,
EMPromise.resolve(nil),
["catapult_cred-customer_test@jmp.chat"]
)
API::REDIS.expect(
:lindex,
EMPromise.resolve(nil),
["catapult_cred-test@example.net", 0]
)
cust = customer(sgx: sgx)
assert cust.admin_info.sync.fields
assert_mock sgx
end
em :test_admin_info_does_not_crash
def test_inactive_info_does_not_crash
sgx = Minitest::Mock.new
sgx.expect(:registered?, EMPromise.resolve(nil))
plan = CustomerPlan.new("test", plan: nil, expires_at: nil)
cust = Customer.new(
"test",
Blather::JID.new("test@example.net"),
plan: plan,
sgx: sgx
)
assert cust.info.sync.fields
assert_mock sgx
end
em :test_inactive_info_does_not_crash
def test_inactive_admin_info_does_not_crash
sgx = Minitest::Mock.new
sgx.expect(:registered?, EMPromise.resolve(nil))
API::REDIS.expect(
:exists,
EMPromise.resolve(nil),
["catapult_cred-customer_test@jmp.chat"]
)
API::REDIS.expect(
:lindex,
EMPromise.resolve(nil),
["catapult_cred-test@example.net", 0]
)
plan = CustomerPlan.new("test", plan: nil, expires_at: nil)
cust = Customer.new(
"test",
Blather::JID.new("test@example.net"),
plan: plan,
sgx: sgx
)
assert cust.admin_info.sync.fields
assert_mock sgx
end
em :test_inactive_admin_info_does_not_crash
def test_legacy_customer_info_does_not_crash
cust = LegacyCustomer.new(
Blather::JID.new("legacy@example.com"),
"+12223334444"
)
assert cust.info.sync.fields
end
em :test_legacy_customer_info_does_not_crash
def test_legacy_customer_admin_info_does_not_crash
API::REDIS.expect(
:exists,
EMPromise.resolve(nil),
["catapult_cred-customer_@jmp.chat"]
)
API::REDIS.expect(
:lindex,
EMPromise.resolve(nil),
["catapult_cred-legacy@example.com", 0]
)
cust = LegacyCustomer.new(
Blather::JID.new("legacy@example.com"),
"+12223334444"
)
assert cust.admin_info.sync.fields
end
em :test_legacy_customer_admin_info_does_not_crash
end