@@ -922,7 +922,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
922922 describe ( "Regex step" , ( ) => {
923923 it ( "replaces matches with replacement string" , ( ) => {
924924 const flattened = createFlattened ( { title : "Hello World" } ) ;
925- const result = processCustomPlaceholders ( flattened , [
925+ const { flattened : result } = processCustomPlaceholders ( flattened , [
926926 {
927927 id : "test" ,
928928 referenceName : "test" ,
@@ -941,7 +941,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
941941
942942 it ( "does not modify source placeholder" , ( ) => {
943943 const flattened = createFlattened ( { title : "Hello World" } ) ;
944- const result = processCustomPlaceholders ( flattened , [
944+ const { flattened : result } = processCustomPlaceholders ( flattened , [
945945 {
946946 id : "test" ,
947947 referenceName : "test" ,
@@ -960,7 +960,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
960960
961961 it ( "replaces with empty string if no replacement specified" , ( ) => {
962962 const flattened = createFlattened ( { title : "Hello World" } ) ;
963- const result = processCustomPlaceholders ( flattened , [
963+ const { flattened : result } = processCustomPlaceholders ( flattened , [
964964 {
965965 id : "test" ,
966966 referenceName : "test" ,
@@ -978,7 +978,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
978978
979979 it ( "replaces globally" , ( ) => {
980980 const flattened = createFlattened ( { title : "Hello Hello World" } ) ;
981- const result = processCustomPlaceholders ( flattened , [
981+ const { flattened : result } = processCustomPlaceholders ( flattened , [
982982 {
983983 id : "test" ,
984984 referenceName : "test" ,
@@ -997,7 +997,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
997997
998998 it ( "replaces case-insensitively by default" , ( ) => {
999999 const flattened = createFlattened ( { title : "hello HELLO world" } ) ;
1000- const result = processCustomPlaceholders ( flattened , [
1000+ const { flattened : result } = processCustomPlaceholders ( flattened , [
10011001 {
10021002 id : "test" ,
10031003 referenceName : "test" ,
@@ -1016,7 +1016,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
10161016
10171017 it ( "chains multiple steps" , ( ) => {
10181018 const flattened = createFlattened ( { title : "hello world" } ) ;
1019- const result = processCustomPlaceholders ( flattened , [
1019+ const { flattened : result } = processCustomPlaceholders ( flattened , [
10201020 {
10211021 id : "test" ,
10221022 referenceName : "test" ,
@@ -1037,12 +1037,36 @@ Centro comercial Moctezuma Francisco Chang Mexico
10371037 ] ) ;
10381038 expect ( result [ "custom::test" ] ) . toBe ( "farewell world" ) ;
10391039 } ) ;
1040+
1041+ it ( "returns previews with intermediate step outputs" , ( ) => {
1042+ const flattened = createFlattened ( { title : "hello world" } ) ;
1043+ const { previews } = processCustomPlaceholders ( flattened , [
1044+ {
1045+ id : "test" ,
1046+ referenceName : "test" ,
1047+ sourcePlaceholder : "title" ,
1048+ steps : [
1049+ {
1050+ type : CustomPlaceholderStepType . Regex ,
1051+ regexSearch : "hello" ,
1052+ replacementString : "goodbye" ,
1053+ } ,
1054+ {
1055+ type : CustomPlaceholderStepType . Uppercase ,
1056+ } ,
1057+ ] ,
1058+ } ,
1059+ ] ) ;
1060+ expect ( previews ) . toEqual ( [
1061+ [ "hello world" , "goodbye world" , "GOODBYE WORLD" ] ,
1062+ ] ) ;
1063+ } ) ;
10401064 } ) ;
10411065
10421066 describe ( "UrlEncode step" , ( ) => {
10431067 it ( "URL encodes the value" , ( ) => {
10441068 const flattened = createFlattened ( { title : "Hello World!" } ) ;
1045- const result = processCustomPlaceholders ( flattened , [
1069+ const { flattened : result } = processCustomPlaceholders ( flattened , [
10461070 {
10471071 id : "test" ,
10481072 referenceName : "test" ,
@@ -1057,7 +1081,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
10571081 const flattened = createFlattened ( {
10581082 title : "foo=bar&baz=qux?test#hash" ,
10591083 } ) ;
1060- const result = processCustomPlaceholders ( flattened , [
1084+ const { flattened : result } = processCustomPlaceholders ( flattened , [
10611085 {
10621086 id : "test" ,
10631087 referenceName : "test" ,
@@ -1074,7 +1098,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
10741098 describe ( "DateFormat step" , ( ) => {
10751099 it ( "formats a valid date" , ( ) => {
10761100 const flattened = createFlattened ( { date : "2023-06-15T10:30:00Z" } ) ;
1077- const result = processCustomPlaceholders ( flattened , [
1101+ const { flattened : result } = processCustomPlaceholders ( flattened , [
10781102 {
10791103 id : "test" ,
10801104 referenceName : "test" ,
@@ -1092,7 +1116,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
10921116
10931117 it ( "applies timezone" , ( ) => {
10941118 const flattened = createFlattened ( { date : "2023-06-15T10:30:00Z" } ) ;
1095- const result = processCustomPlaceholders ( flattened , [
1119+ const { flattened : result } = processCustomPlaceholders ( flattened , [
10961120 {
10971121 id : "test" ,
10981122 referenceName : "test" ,
@@ -1112,7 +1136,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
11121136
11131137 it ( "returns empty string for invalid date" , ( ) => {
11141138 const flattened = createFlattened ( { date : "not-a-date" } ) ;
1115- const result = processCustomPlaceholders ( flattened , [
1139+ const { flattened : result } = processCustomPlaceholders ( flattened , [
11161140 {
11171141 id : "test" ,
11181142 referenceName : "test" ,
@@ -1130,7 +1154,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
11301154
11311155 it ( "returns empty string for invalid timezone" , ( ) => {
11321156 const flattened = createFlattened ( { date : "2023-06-15T10:30:00Z" } ) ;
1133- const result = processCustomPlaceholders ( flattened , [
1157+ const { flattened : result } = processCustomPlaceholders ( flattened , [
11341158 {
11351159 id : "test" ,
11361160 referenceName : "test" ,
@@ -1151,7 +1175,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
11511175 describe ( "Uppercase step" , ( ) => {
11521176 it ( "converts to uppercase" , ( ) => {
11531177 const flattened = createFlattened ( { title : "Hello World" } ) ;
1154- const result = processCustomPlaceholders ( flattened , [
1178+ const { flattened : result } = processCustomPlaceholders ( flattened , [
11551179 {
11561180 id : "test" ,
11571181 referenceName : "test" ,
@@ -1166,7 +1190,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
11661190 describe ( "Lowercase step" , ( ) => {
11671191 it ( "converts to lowercase" , ( ) => {
11681192 const flattened = createFlattened ( { title : "Hello World" } ) ;
1169- const result = processCustomPlaceholders ( flattened , [
1193+ const { flattened : result } = processCustomPlaceholders ( flattened , [
11701194 {
11711195 id : "test" ,
11721196 referenceName : "test" ,
@@ -1181,7 +1205,7 @@ Centro comercial Moctezuma Francisco Chang Mexico
11811205 describe ( "missing source placeholder" , ( ) => {
11821206 it ( "returns empty string if source does not exist" , ( ) => {
11831207 const flattened = createFlattened ( { } ) ;
1184- const result = processCustomPlaceholders ( flattened , [
1208+ const { flattened : result } = processCustomPlaceholders ( flattened , [
11851209 {
11861210 id : "test" ,
11871211 referenceName : "test" ,
0 commit comments