package com.ruoyi.app.pay;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class LinePayReturnPageRendererTest {

    @Test
    void fixedDeepLinkUrlEncodesOrderAndHtmlDoesNotInjectItIntoScript() {
        LinePayReturnPageRenderer renderer = new LinePayReturnPageRenderer();

        String html = renderer.render("DD-1\"</script><script>alert(1)</script>");

        assertTrue(html.contains("com.twanmsdyh.app://payment/result?orderId=DD-1%22%3C%2Fscript%3E%3Cscript%3Ealert%281%29%3C%2Fscript%3E"));
        assertFalse(html.contains("</script><script>alert(1)</script>"));
        assertTrue(html.contains("Payment is being confirmed"));
        assertTrue(html.contains("Open app"));
    }
}

