import{getScriptLoadParams}from"../functions";describe("Paypal Buttons Functions",(()=>{describe("getScriptLoadParams",(()=>{it("should not use merchant_id for CIB subscriptions",(()=>{expect(getScriptLoadParams({clientId:"client_id",reusable:!0,merchantId:"merchant_id",currency:"eur",merchantInitiated:!1})).toEqual({"client-id":"client_id",commit:!1,intent:"tokenize",vault:!0,currency:"EUR"})})),it("should use merchant_id for MIB subscriptions",(()=>{expect(getScriptLoadParams({clientId:"client_id",reusable:!0,merchantId:"merchant_id",currency:"eur",merchantInitiated:!0})).toEqual({"client-id":"client_id",commit:!1,intent:"tokenize","merchant-id":"merchant_id",vault:!0,currency:"EUR"})})),it("should include locale in params with underscore format when provided",(()=>{expect(getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"eur",merchantInitiated:!1,locale:"de-DE"})).toEqual({"client-id":"client_id",commit:!1,intent:"capture",vault:!0,"merchant-id":"merchant_id",currency:"EUR",locale:"de_DE"})})),it("should omit locale when not provided",(()=>{const e=getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"eur",merchantInitiated:!1});expect(e.locale).toBeUndefined()})),it("should handle multi-hyphen locales like zh-Hant-TW",(()=>{const e=getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"usd",merchantInitiated:!1,locale:"zh-Hant-TW"});expect(e.locale).toBe("zh_Hant_TW")})),it("should omit locale when input is null",(()=>{const e=getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"usd",merchantInitiated:!1,locale:null});expect(e.locale).toBeUndefined()})),it("should omit locale when input is an empty string",(()=>{const e=getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"usd",merchantInitiated:!1,locale:""});expect(e.locale).toBeUndefined()})),it("should omit locale when input is a bare language code (en)",(()=>{const e=getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"usd",merchantInitiated:!1,locale:"en"});expect(e.locale).toBeUndefined()})),it("should omit locale when input is a bare language code (de)",(()=>{const e=getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"usd",merchantInitiated:!1,locale:"de"});expect(e.locale).toBeUndefined()})),it("should use a merchant_id for a non-subscription order (regardless of CIB/MIB)",(()=>{expect(getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"eur",merchantInitiated:!1})).toEqual({"client-id":"client_id",commit:!1,intent:"capture",vault:!0,"merchant-id":"merchant_id",currency:"EUR"}),expect(getScriptLoadParams({clientId:"client_id",reusable:!1,merchantId:"merchant_id",currency:"eur",merchantInitiated:!0})).toEqual({"client-id":"client_id",commit:!1,intent:"capture",vault:!0,"merchant-id":"merchant_id",currency:"EUR"})}))}))}));