1- import { existsSync , mkdirSync , readFileSync , readdirSync } from 'fs' ;
1+ import { existsSync , mkdirSync , readdirSync , readFileSync } from 'fs' ;
22import * as yaml from 'js-yaml' ;
33import { join } from 'path' ;
44
@@ -35,142 +35,145 @@ describe('BuilderManager Tests', () => {
3535 const loadYamlFiles = ( dir : string ) : Record < string , any > => {
3636 const yamlFiles : Record < string , any > = { } ;
3737 const files = getAllYamlFiles ( dir ) ;
38-
39- files . forEach ( filePath => {
38+
39+ files . forEach ( ( filePath ) => {
4040 const relativePath = filePath . replace ( dir + '/' , '' ) ;
4141 const content = readFileSync ( filePath , 'utf-8' ) ;
4242 yamlFiles [ relativePath ] = yaml . load ( content ) ;
4343 } ) ;
44-
44+
4545 return yamlFiles ;
4646 } ;
4747
4848 describe ( 'Single Chain Generation' , ( ) => {
4949 it ( 'should generate complete single-chain setup with proper directory organization' , ( ) => {
5050 const manager = new BuilderManager ( singleChainConfig ) ;
51-
51+
5252 const testSubDir = join ( testOutputDir , 'single-chain' ) ;
5353 manager . build ( testSubDir ) ;
54-
54+
5555 // Verify files were generated
5656 const files = getAllYamlFiles ( testSubDir ) ;
5757 expect ( files . length ) . toBeGreaterThan ( 0 ) ;
58-
58+
5959 // Load and snapshot all YAML files
6060 const yamlFiles = loadYamlFiles ( testSubDir ) ;
6161 expect ( yamlFiles ) . toMatchSnapshot ( 'single-chain-yaml-files' ) ;
62-
62+
6363 // Verify directory structure
6464 const directories = readdirSync ( testSubDir , { withFileTypes : true } )
65- . filter ( item => item . isDirectory ( ) )
66- . map ( item => item . name )
65+ . filter ( ( item ) => item . isDirectory ( ) )
66+ . map ( ( item ) => item . name )
6767 . sort ( ) ;
68-
68+
6969 expect ( directories ) . toMatchSnapshot ( 'single-chain-directory-structure' ) ;
7070 } ) ;
7171 } ) ;
7272
7373 describe ( 'Multi Chain Generation' , ( ) => {
7474 it ( 'should generate complete multi-chain setup with proper directory organization' , ( ) => {
7575 const manager = new BuilderManager ( twoChainConfig ) ;
76-
76+
7777 const testSubDir = join ( testOutputDir , 'multi-chain' ) ;
7878 manager . build ( testSubDir ) ;
79-
79+
8080 // Verify files were generated
8181 const files = getAllYamlFiles ( testSubDir ) ;
8282 expect ( files . length ) . toBeGreaterThan ( 0 ) ;
83-
83+
8484 // Load and snapshot all YAML files
8585 const yamlFiles = loadYamlFiles ( testSubDir ) ;
8686 expect ( yamlFiles ) . toMatchSnapshot ( 'multi-chain-yaml-files' ) ;
87-
87+
8888 // Verify directory structure
8989 const directories = readdirSync ( testSubDir , { withFileTypes : true } )
90- . filter ( item => item . isDirectory ( ) )
91- . map ( item => item . name )
90+ . filter ( ( item ) => item . isDirectory ( ) )
91+ . map ( ( item ) => item . name )
9292 . sort ( ) ;
93-
93+
9494 expect ( directories ) . toMatchSnapshot ( 'multi-chain-directory-structure' ) ;
95-
95+
9696 // Verify each chain directory has the correct files
97- const chainDirectories = directories . filter ( dir =>
98- dir !== 'configmaps' && dir !== 'explorer' && dir !== 'registry'
97+ const chainDirectories = directories . filter (
98+ ( dir ) =>
99+ dir !== 'configmaps' && dir !== 'explorer' && dir !== 'registry'
99100 ) ;
100-
101+
101102 const chainStructure : Record < string , string [ ] > = { } ;
102- chainDirectories . forEach ( chainDir => {
103+ chainDirectories . forEach ( ( chainDir ) => {
103104 const chainPath = join ( testSubDir , chainDir ) ;
104105 const chainFiles = readdirSync ( chainPath )
105- . filter ( file => file . endsWith ( '.yaml' ) )
106+ . filter ( ( file ) => file . endsWith ( '.yaml' ) )
106107 . sort ( ) ;
107108 chainStructure [ chainDir ] = chainFiles ;
108109 } ) ;
109-
110+
110111 expect ( chainStructure ) . toMatchSnapshot ( 'chain-directory-contents' ) ;
111112 } ) ;
112113 } ) ;
113114
114115 describe ( 'Directory Organization Validation' , ( ) => {
115116 it ( 'should organize files with correct naming patterns' , ( ) => {
116117 const manager = new BuilderManager ( twoChainConfig ) ;
117-
118+
118119 const testSubDir = join ( testOutputDir , 'organization-validation' ) ;
119120 manager . build ( testSubDir ) ;
120-
121+
121122 const files = getAllYamlFiles ( testSubDir ) ;
122-
123+
123124 // Group files by their directory and analyze naming patterns
124125 const fileStructure : Record < string , string [ ] > = { } ;
125- files . forEach ( filePath => {
126+ files . forEach ( ( filePath ) => {
126127 const relativePath = filePath . replace ( testSubDir + '/' , '' ) ;
127128 const parts = relativePath . split ( '/' ) ;
128129 const directory = parts [ 0 ] ;
129130 const fileName = parts [ parts . length - 1 ] ;
130-
131+
131132 if ( ! fileStructure [ directory ] ) {
132133 fileStructure [ directory ] = [ ] ;
133134 }
134135 fileStructure [ directory ] . push ( fileName ) ;
135136 } ) ;
136-
137+
137138 // Sort for consistent snapshots
138- Object . keys ( fileStructure ) . forEach ( dir => {
139+ Object . keys ( fileStructure ) . forEach ( ( dir ) => {
139140 fileStructure [ dir ] . sort ( ) ;
140141 } ) ;
141-
142+
142143 expect ( fileStructure ) . toMatchSnapshot ( 'file-organization-structure' ) ;
143-
144+
144145 // Verify chain directories don't have redundant prefixes
145- const chainDirs = Object . keys ( fileStructure ) . filter ( dir =>
146- ! [ 'configmaps' , 'explorer' , 'registry' ] . includes ( dir )
146+ const chainDirs = Object . keys ( fileStructure ) . filter (
147+ ( dir ) => ! [ 'configmaps' , 'explorer' , 'registry' ] . includes ( dir )
147148 ) ;
148-
149- chainDirs . forEach ( chainDir => {
149+
150+ chainDirs . forEach ( ( chainDir ) => {
150151 const files = fileStructure [ chainDir ] ;
151152 // Chain files should have role-kind pattern (e.g., genesis-service.yaml)
152- files . forEach ( file => {
153+ files . forEach ( ( file ) => {
153154 if ( file . includes ( 'service' ) || file . includes ( 'statefulset' ) ) {
154- expect ( file ) . toMatch ( / ^ ( g e n e s i s | v a l i d a t o r ) - ( s e r v i c e | s t a t e f u l s e t ) \. y a m l $ / ) ;
155+ expect ( file ) . toMatch (
156+ / ^ ( g e n e s i s | v a l i d a t o r ) - ( s e r v i c e | s t a t e f u l s e t ) \. y a m l $ /
157+ ) ;
155158 }
156159 } ) ;
157160 } ) ;
158-
161+
159162 // Verify component directories have clean names (no redundant prefixes)
160- [ 'explorer' , 'registry' ] . forEach ( component => {
163+ [ 'explorer' , 'registry' ] . forEach ( ( component ) => {
161164 if ( fileStructure [ component ] ) {
162165 const files = fileStructure [ component ] ;
163- files . forEach ( file => {
166+ files . forEach ( ( file ) => {
164167 // Should not have component prefix (e.g., should be 'service.yaml', not 'explorer-service.yaml')
165168 expect ( file ) . not . toMatch ( new RegExp ( `^${ component } -` ) ) ;
166169 } ) ;
167170 }
168171 } ) ;
169-
172+
170173 // Verify configmaps directory has clean names (no redundant suffixes)
171174 if ( fileStructure [ 'configmaps' ] ) {
172175 const files = fileStructure [ 'configmaps' ] ;
173- files . forEach ( file => {
176+ files . forEach ( ( file ) => {
174177 // Should not have -configmap suffix (e.g., should be 'keys.yaml', not 'keys-configmap.yaml')
175178 expect ( file ) . not . toMatch ( / - c o n f i g m a p \. y a m l $ / ) ;
176179 } ) ;
@@ -181,39 +184,43 @@ describe('BuilderManager Tests', () => {
181184 describe ( 'File Content Validation' , ( ) => {
182185 it ( 'should generate valid YAML with correct resource types' , ( ) => {
183186 const manager = new BuilderManager ( singleChainConfig ) ;
184-
187+
185188 const testSubDir = join ( testOutputDir , 'content-validation' ) ;
186189 manager . build ( testSubDir ) ;
187-
190+
188191 const yamlFiles = loadYamlFiles ( testSubDir ) ;
189-
192+
190193 // Verify all files are valid YAML and have expected structure
191194 Object . entries ( yamlFiles ) . forEach ( ( [ filePath , content ] ) => {
192195 expect ( content ) . toBeDefined ( ) ;
193196 expect ( content . apiVersion ) . toBeDefined ( ) ;
194197 expect ( content . kind ) . toBeDefined ( ) ;
195198 expect ( content . metadata ) . toBeDefined ( ) ;
196199 expect ( content . metadata . name ) . toBeDefined ( ) ;
197-
200+
198201 // Verify labels exist for chain components
199202 if ( filePath . includes ( 'osmosis/' ) || filePath . includes ( 'cosmoshub/' ) ) {
200203 expect ( content . metadata . labels ) . toBeDefined ( ) ;
201- expect ( content . metadata . labels [ 'app.kubernetes.io/component' ] ) . toBe ( 'chain' ) ;
204+ expect ( content . metadata . labels [ 'app.kubernetes.io/component' ] ) . toBe (
205+ 'chain'
206+ ) ;
202207 // Only check starship.io/chain-name for Services and StatefulSets (not ConfigMaps)
203208 if ( content . kind === 'Service' || content . kind === 'StatefulSet' ) {
204- expect ( content . metadata . labels [ 'starship.io/chain-name' ] ) . toBeDefined ( ) ;
209+ expect (
210+ content . metadata . labels [ 'starship.io/chain-name' ]
211+ ) . toBeDefined ( ) ;
205212 }
206213 }
207214 } ) ;
208-
215+
209216 // Count resources by type
210217 const resourceCounts : Record < string , number > = { } ;
211218 Object . values ( yamlFiles ) . forEach ( ( content : any ) => {
212219 const kind = content . kind ;
213220 resourceCounts [ kind ] = ( resourceCounts [ kind ] || 0 ) + 1 ;
214221 } ) ;
215-
222+
216223 expect ( resourceCounts ) . toMatchSnapshot ( 'resource-type-counts' ) ;
217224 } ) ;
218225 } ) ;
219- } ) ;
226+ } ) ;
0 commit comments