Add WhatsApp numbers/links
This commit is contained in:
@@ -295,4 +295,41 @@ module('Integration | Component | place-details', function (hooks) {
|
||||
assert.dom(links[1]).hasText('+1 000 000 0000');
|
||||
assert.dom(links[2]).hasText('+1 987 654 3210');
|
||||
});
|
||||
|
||||
test('it formats whatsapp tags into wa.me links', async function (assert) {
|
||||
const place = {
|
||||
title: 'Chat Shop',
|
||||
osmTags: {
|
||||
'contact:whatsapp': '+1 234-567 8900',
|
||||
whatsapp: '+44 987 654 321', // Also tests multiple values
|
||||
},
|
||||
};
|
||||
|
||||
await render(<template><PlaceDetails @place={{place}} /></template>);
|
||||
|
||||
const metaInfos = Array.from(
|
||||
this.element.querySelectorAll('.meta-info .content-with-icon')
|
||||
);
|
||||
const whatsappBlock = metaInfos.find((el) => {
|
||||
const iconSpan = el.querySelector('span.icon[title="WhatsApp"]');
|
||||
return !!iconSpan;
|
||||
});
|
||||
|
||||
assert.ok(whatsappBlock, 'WhatsApp block is rendered');
|
||||
|
||||
const links = whatsappBlock.querySelectorAll('a[href^="https://wa.me/"]');
|
||||
assert.strictEqual(
|
||||
links.length,
|
||||
2,
|
||||
'Rendered exactly 2 WhatsApp links'
|
||||
);
|
||||
|
||||
// Verify it stripped the dashes and spaces for the wa.me URL
|
||||
assert.strictEqual(links[0].getAttribute('href'), 'https://wa.me/+44987654321');
|
||||
assert.strictEqual(links[1].getAttribute('href'), 'https://wa.me/+12345678900');
|
||||
|
||||
// Verify it kept the dashes and spaces for the visible text
|
||||
assert.dom(links[0]).hasText('+44 987 654 321');
|
||||
assert.dom(links[1]).hasText('+1 234-567 8900');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user