1- import { Map , fromJS } from "immutable"
1+ import { Map , fromJS , OrderedMap } from "immutable"
22import {
33 mapToList ,
44 parseSearch ,
@@ -23,6 +23,7 @@ import {
2323 requiresValidationURL ,
2424 extractFileNameFromContentDispositionHeader ,
2525 deeplyStripKey ,
26+ stringify ,
2627 paramToIdentifier ,
2728 paramToValue ,
2829 generateCodeVerifier ,
@@ -1310,6 +1311,37 @@ describe("utils", () => {
13101311 } )
13111312 } )
13121313
1314+ describe ( "stringify" , ( ) => {
1315+ it ( "returns the string as-is" , ( ) => {
1316+ expect ( stringify ( "hello" ) ) . toBe ( "hello" )
1317+ } )
1318+
1319+ it ( "converts Immutable objects to plain JS and stringifies" , ( ) => {
1320+ const immutableMap = OrderedMap ( { key : "value" } )
1321+ expect ( stringify ( immutableMap ) ) . toBe ( '{\n "key": "value"\n}' )
1322+ } )
1323+
1324+ it ( "stringifies plain JS objects" , ( ) => {
1325+ const obj = { key : "value" }
1326+ expect ( stringify ( obj ) ) . toBe ( '{\n "key": "value"\n}' )
1327+ } )
1328+
1329+ it ( "returns empty string for null or undefined" , ( ) => {
1330+ expect ( stringify ( null ) ) . toBe ( "" )
1331+ expect ( stringify ( undefined ) ) . toBe ( "" )
1332+ } )
1333+
1334+ it ( "calls toString for numbers" , ( ) => {
1335+ expect ( stringify ( 42 ) ) . toBe ( "42" )
1336+ } )
1337+
1338+ it ( "falls back to String() on JSON.stringify error" , ( ) => {
1339+ const circularObj = { }
1340+ circularObj . self = circularObj
1341+ expect ( stringify ( circularObj ) ) . toBe ( "[object Object]" )
1342+ } )
1343+ } )
1344+
13131345 describe ( "parse and serialize search" , ( ) => {
13141346 beforeEach ( ( ) => {
13151347 // jsdom in Jest 25+ prevents modifying window.location,
0 commit comments