@@ -69,6 +69,97 @@ describe('translateOptions', () => {
6969 const result = translateOptions ( options ) ;
7070 expect ( result . output ) . toBe ( 'v42.ppk' ) ;
7171 } ) ;
72+
73+ test ( 'handles boolean values in template' , ( ) => {
74+ const options = {
75+ flag : false ,
76+ output : `is-false-${ templateVar ( 'flag' ) } .ppk` ,
77+ } ;
78+ const result = translateOptions ( options ) ;
79+ expect ( result . output ) . toBe ( 'is-false-false.ppk' ) ;
80+ } ) ;
81+
82+ test ( 'handles zero numeric values in template' , ( ) => {
83+ const options = {
84+ count : 0 ,
85+ output : `v${ templateVar ( 'count' ) } .ppk` ,
86+ } ;
87+ const result = translateOptions ( options ) ;
88+ expect ( result . output ) . toBe ( 'v0.ppk' ) ;
89+ } ) ;
90+
91+ test ( 'handles empty string values in template' , ( ) => {
92+ const options = {
93+ empty : '' ,
94+ output : `pre-${ templateVar ( 'empty' ) } -post.ppk` ,
95+ } ;
96+ const result = translateOptions ( options ) ;
97+ expect ( result . output ) . toBe ( 'pre--post.ppk' ) ;
98+ } ) ;
99+
100+ test ( 'ignores object values in template and leaves placeholder' , ( ) => {
101+ const options = {
102+ obj : { key : 'value' } ,
103+ output : `obj-${ templateVar ( 'obj' ) } .ppk` ,
104+ } ;
105+ const result = translateOptions ( options ) ;
106+ expect ( result . output ) . toBe ( `obj-${ templateVar ( 'obj' ) } .ppk` ) ;
107+ } ) ;
108+
109+ test ( 'ignores array values in template and leaves placeholder' , ( ) => {
110+ const options = {
111+ arr : [ 1 , 2 , 3 ] ,
112+ output : `arr-${ templateVar ( 'arr' ) } .ppk` ,
113+ } ;
114+ const result = translateOptions ( options ) ;
115+ expect ( result . output ) . toBe ( `arr-${ templateVar ( 'arr' ) } .ppk` ) ;
116+ } ) ;
117+
118+ test ( 'replaces multiple identical placeholders' , ( ) => {
119+ const options = {
120+ val : 'test' ,
121+ output : `${ templateVar ( 'val' ) } -${ templateVar ( 'val' ) } .ppk` ,
122+ } ;
123+ const result = translateOptions ( options ) ;
124+ expect ( result . output ) . toBe ( 'test-test.ppk' ) ;
125+ } ) ;
126+
127+ describe ( 'translateOptions with map' , ( ) => {
128+ test ( 'maps keys according to the provided map' , ( ) => {
129+ const options = { oldKey : 'value' , keepKey : 'keep' } ;
130+ const map = { oldKey : 'newKey' } ;
131+ const result = translateOptions ( options , map ) ;
132+ expect ( result ) . toEqual ( { newKey : 'value' , keepKey : 'keep' } ) ;
133+ } ) ;
134+
135+ test ( 'ignores missing keys in options' , ( ) => {
136+ const options = { existingKey : 'value' } ;
137+ const map = { missingKey : 'newKey' } ;
138+ const result = translateOptions ( options , map ) ;
139+ expect ( result ) . toEqual ( { existingKey : 'value' } ) ;
140+ } ) ;
141+
142+ test ( 'maps multiple keys' , ( ) => {
143+ const options = { a : 1 , b : 2 , c : 3 } ;
144+ const map = { a : 'alpha' , b : 'beta' } ;
145+ const result = translateOptions ( options , map ) ;
146+ expect ( result ) . toEqual ( { alpha : 1 , beta : 2 , c : 3 } ) ;
147+ } ) ;
148+
149+ test ( 'handles mapping to existing keys by overwriting' , ( ) => {
150+ const options = { a : 1 , b : 2 } ;
151+ const map = { a : 'b' } ;
152+ const result = translateOptions ( options , map ) ;
153+ expect ( result ) . toEqual ( { b : 1 } ) ;
154+ } ) ;
155+
156+ test ( 'handles undefined values' , ( ) => {
157+ const options = { a : undefined , b : null } ;
158+ const map = { a : 'newA' , b : 'newB' } ;
159+ const result = translateOptions ( options , map ) ;
160+ expect ( result ) . toEqual ( { a : undefined , newB : null } ) ;
161+ } ) ;
162+ } ) ;
72163} ) ;
73164
74165describe ( 'isNonInteractive' , ( ) => {
0 commit comments