From 748117f199fcebd596a2079eea03ca5a14f7fe3e Mon Sep 17 00:00:00 2001 From: Dmitry Shovchko Date: Wed, 13 Dec 2023 15:40:53 +0200 Subject: [PATCH] feat(esl-share): add OOTB configuration for the WhatsApp share button --- src/modules/esl-share/README.md | 1 + src/modules/esl-share/buttons/all.ts | 1 + src/modules/esl-share/buttons/whatsapp.ts | 14 ++++++++++++++ .../esl-share/test/buttons/whatsapp.test.ts | 13 +++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 src/modules/esl-share/buttons/whatsapp.ts create mode 100644 src/modules/esl-share/test/buttons/whatsapp.test.ts diff --git a/src/modules/esl-share/README.md b/src/modules/esl-share/README.md index e879c5ca6..ff707f724 100644 --- a/src/modules/esl-share/README.md +++ b/src/modules/esl-share/README.md @@ -377,6 +377,7 @@ Here is the list of available buttons for sharing via social media and messenger - `sina-weibo` - shares data into Sina Weibo a microblogging website and app which compares to Twitter and Instagram - `telegram` - shares data into Telegram a cloud-based, cross-platform instant messaging (IM) service - `twitter` - shares data into Twitter a free social networking site where users broadcast short posts known as tweets + - `whatsapp` - shares data into WhatsApp a free cross-platform messaging service - `wykop` - shares data into Wykop a Polish social networking internet service And the list of available buttons for other sharing actions: diff --git a/src/modules/esl-share/buttons/all.ts b/src/modules/esl-share/buttons/all.ts index f8c3a53f3..3b31fdd6d 100644 --- a/src/modules/esl-share/buttons/all.ts +++ b/src/modules/esl-share/buttons/all.ts @@ -17,4 +17,5 @@ import './reddit'; import './sina-weibo'; import './telegram'; import './twitter'; +import './whatsapp'; import './wykop'; diff --git a/src/modules/esl-share/buttons/whatsapp.ts b/src/modules/esl-share/buttons/whatsapp.ts new file mode 100644 index 000000000..9cfe47743 --- /dev/null +++ b/src/modules/esl-share/buttons/whatsapp.ts @@ -0,0 +1,14 @@ +/* eslint-disable max-len */ +import '../actions/media-action'; +import {ESLShareConfig} from '../core/esl-share-config'; + +import type {ESLShareButtonConfig} from '../core/esl-share-config'; + +export const whatsapp: ESLShareButtonConfig = { + action: 'media', + icon: '', + link: '//api.whatsapp.com/send?text={t}&url={u}', + name: 'whatsapp', + title: 'WhatsApp' +}; +ESLShareConfig.append(whatsapp); diff --git a/src/modules/esl-share/test/buttons/whatsapp.test.ts b/src/modules/esl-share/test/buttons/whatsapp.test.ts new file mode 100644 index 000000000..1ec7249b6 --- /dev/null +++ b/src/modules/esl-share/test/buttons/whatsapp.test.ts @@ -0,0 +1,13 @@ +import {createImportCheckTestPlan, createButtonMatchingTestPlan} from './button-test-plan-factory'; + +import '../../buttons/whatsapp'; + +describe( + 'ESLShare: "whatsapp" button import appends button to config and registers the "media" action', + createImportCheckTestPlan('media') +); + +describe( + 'ESLShare: "whatsapp" button object config matches button config', + createButtonMatchingTestPlan('whatsapp', 'media') +);