from __future__ import annotations

from django.test import SimpleTestCase

from core.clients.signal import _extract_signal_text


class SignalTextExtractionTests(SimpleTestCase):
    def test_extracts_emoji_only_data_message_text(self):
        payload = {
            "envelope": {
                "dataMessage": {
                    "message": "🙂",
                }
            }
        }
        self.assertEqual("🙂", _extract_signal_text(payload, ""))

    def test_extracts_sync_sent_message_fallback(self):
        payload = {
            "envelope": {
                "syncMessage": {
                    "sentMessage": {
                        "message": {
                            "message": "ok 👍",
                        }
                    }
                }
            }
        }
        self.assertEqual("ok 👍", _extract_signal_text(payload, ""))
