Fix lint errors
This commit is contained in:
@@ -142,10 +142,12 @@ export default class PlaceDetails extends Component {
|
|||||||
|
|
||||||
if (type === 'phone') {
|
if (type === 'phone') {
|
||||||
return htmlSafe(
|
return htmlSafe(
|
||||||
parts.map((p) => {
|
parts
|
||||||
const safeTel = p.replace(/[\s-]+/g, '');
|
.map((p) => {
|
||||||
return `<a href="tel:${safeTel}">${p}</a>`;
|
const safeTel = p.replace(/[\s-]+/g, '');
|
||||||
}).join('<br>')
|
return `<a href="tel:${safeTel}">${p}</a>`;
|
||||||
|
})
|
||||||
|
.join('<br>')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,10 +159,12 @@ export default class PlaceDetails extends Component {
|
|||||||
|
|
||||||
if (type === 'whatsapp') {
|
if (type === 'whatsapp') {
|
||||||
return htmlSafe(
|
return htmlSafe(
|
||||||
parts.map((p) => {
|
parts
|
||||||
const safeTel = p.replace(/[\s-]+/g, '');
|
.map((p) => {
|
||||||
return `<a href="https://wa.me/${safeTel}" target="_blank" rel="noopener noreferrer">${p}</a>`;
|
const safeTel = p.replace(/[\s-]+/g, '');
|
||||||
}).join('<br>')
|
return `<a href="https://wa.me/${safeTel}" target="_blank" rel="noopener noreferrer">${p}</a>`;
|
||||||
|
})
|
||||||
|
.join('<br>')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -318,15 +318,17 @@ module('Integration | Component | place-details', function (hooks) {
|
|||||||
assert.ok(whatsappBlock, 'WhatsApp block is rendered');
|
assert.ok(whatsappBlock, 'WhatsApp block is rendered');
|
||||||
|
|
||||||
const links = whatsappBlock.querySelectorAll('a[href^="https://wa.me/"]');
|
const links = whatsappBlock.querySelectorAll('a[href^="https://wa.me/"]');
|
||||||
assert.strictEqual(
|
assert.strictEqual(links.length, 2, 'Rendered exactly 2 WhatsApp links');
|
||||||
links.length,
|
|
||||||
2,
|
|
||||||
'Rendered exactly 2 WhatsApp links'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify it stripped the dashes and spaces for the wa.me URL
|
// Verify it stripped the dashes and spaces for the wa.me URL
|
||||||
assert.strictEqual(links[0].getAttribute('href'), 'https://wa.me/+44987654321');
|
assert.strictEqual(
|
||||||
assert.strictEqual(links[1].getAttribute('href'), 'https://wa.me/+12345678900');
|
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
|
// Verify it kept the dashes and spaces for the visible text
|
||||||
assert.dom(links[0]).hasText('+44 987 654 321');
|
assert.dom(links[0]).hasText('+44 987 654 321');
|
||||||
|
|||||||
Reference in New Issue
Block a user