fix: specs

This commit is contained in:
Muhsin Keloth
2024-02-07 14:34:11 +05:30
parent b125ac1ad6
commit 07a7c1eb8b
3 changed files with 11 additions and 8 deletions
@@ -28,6 +28,7 @@ describe ContactInboxWithContactBuilder do
inbox: inbox,
contact_attributes: {
name: 'Contact',
last_name: '1',
phone_number: '+1234567890',
email: 'testemail@example.com',
custom_attributes: { test: 'test' }
@@ -58,7 +58,7 @@ describe Messages::Facebook::MessageBuilder do
expect(facebook_channel.inbox.reload.contacts.count).to eq(1)
expect(contact.name).to eq(default_name)
expect(contact.last_name).to eq(default_name)
expect(contact.last_name).to eq('Doe')
end
end
end
@@ -20,7 +20,8 @@ describe Whatsapp::IncomingMessageService do
it 'creates appropriate conversations, message and contacts' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
except(Contact.all.first.last_name).to eq('Jose')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Test')
end
@@ -178,7 +179,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('First Button')
end
end
@@ -196,7 +197,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Yes this is a button')
end
end
@@ -219,7 +220,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Check out my product!')
expect(whatsapp_channel.inbox.messages.first.attachments.present?).to be true
end
@@ -240,7 +241,7 @@ describe Whatsapp::IncomingMessageService do
}.with_indifferent_access
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
location_attachment = whatsapp_channel.inbox.messages.first.attachments.first
expect(location_attachment.file_type).to eq('location')
expect(location_attachment.fallback_title).to eq('Bay Bridge, San Francisco, CA, USA')
@@ -290,7 +291,8 @@ describe Whatsapp::IncomingMessageService do
it 'creates appropriate conversations, message and contacts if contact does not exit' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
except(Contact.all.first.last_name).to eq('Jose')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Test')
expect(whatsapp_channel.inbox.contact_inboxes.first.source_id).to eq(wa_id)
end
@@ -337,7 +339,7 @@ describe Whatsapp::IncomingMessageService do
it 'creates contact inbox with the incoming waid' do
described_class.new(inbox: whatsapp_channel.inbox, params: params).perform
expect(whatsapp_channel.inbox.conversations.count).not_to eq(0)
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(Contact.all.first.name).to eq('Sojan')
expect(whatsapp_channel.inbox.messages.first.content).to eq('Test')
expect(whatsapp_channel.inbox.contact_inboxes.first.source_id).to eq(wa_id)
end