@@ -6,7 +6,6 @@ import { describe, expect, it, vi } from 'vitest';
66import findConfig , {
77 forgeConfigIsValidFilePath ,
88 registerForgeConfigForDirectory ,
9- renderConfigTemplate ,
109 unregisterForgeConfigForDirectory ,
1110} from '../../../src/util/forge-config' ;
1211
@@ -78,7 +77,7 @@ describe('findConfig', () => {
7877 '../../fixture/bad_forge_config' ,
7978 ) ;
8079 const err =
81- 'Expected packageJSON. config.forge to be an object or point to a requirable JS file' ;
80+ 'Expected ` config.forge` in package.json to be an object or point to a Forge config file' ;
8281 await expect ( findConfig ( fixturePath ) ) . rejects . toThrow ( err ) ;
8382 } ) ;
8483
@@ -90,7 +89,7 @@ describe('findConfig', () => {
9089 __dirname ,
9190 '../../fixture/bad_external_forge_config' ,
9291 ) ;
93- const err = / U n e x p e c t e d t o k e n / ;
92+ const err = / F a i l e d t o p a r s e / ;
9493 await expect ( findConfig ( fixturePath ) ) . rejects . toThrow ( err ) ;
9594 spy . mockRestore ( ) ;
9695 } ) ;
@@ -294,43 +293,32 @@ describe('findConfig', () => {
294293 } ) ;
295294 } ) ;
296295
297- describe ( 'alternate config formats ' , ( ) => {
298- it ( 'should resolve the yml config from forge.config.yml specified in config.forge ' , async ( ) => {
296+ describe ( 'TypeScript ' , ( ) => {
297+ it ( 'should resolve forge.config.ts ' , async ( ) => {
299298 const fixturePath = path . resolve (
300299 __dirname ,
301- '../../fixture/dummy_ts_conf ' ,
300+ '../../fixture/dummy_default_ts_conf ' ,
302301 ) ;
303302 const conf = await findConfig ( fixturePath ) ;
304- expect ( conf . buildIdentifier ) . toEqual ( 'yml ' ) ;
303+ expect ( conf . buildIdentifier ) . toEqual ( 'typescript ' ) ;
305304 } ) ;
306305
307- describe ( 'TypeScript' , ( ) => {
308- it ( 'should resolve forge.config.ts' , async ( ) => {
309- const fixturePath = path . resolve (
310- __dirname ,
311- '../../fixture/dummy_default_ts_conf' ,
312- ) ;
313- const conf = await findConfig ( fixturePath ) ;
314- expect ( conf . buildIdentifier ) . toEqual ( 'typescript' ) ;
315- } ) ;
316-
317- it ( 'should resolve forge.config.cts' , async ( ) => {
318- const fixturePath = path . resolve (
319- __dirname ,
320- '../../fixture/dummy_default_cts_conf' ,
321- ) ;
322- const conf = await findConfig ( fixturePath ) ;
323- expect ( conf . buildIdentifier ) . toEqual ( 'typescript-commonjs' ) ;
324- } ) ;
306+ it ( 'should resolve forge.config.cts' , async ( ) => {
307+ const fixturePath = path . resolve (
308+ __dirname ,
309+ '../../fixture/dummy_default_cts_conf' ,
310+ ) ;
311+ const conf = await findConfig ( fixturePath ) ;
312+ expect ( conf . buildIdentifier ) . toEqual ( 'typescript-commonjs' ) ;
313+ } ) ;
325314
326- it ( 'should resolve forge.config.mts' , async ( ) => {
327- const fixturePath = path . resolve (
328- __dirname ,
329- '../../fixture/dummy_default_mts_conf' ,
330- ) ;
331- const conf = await findConfig ( fixturePath ) ;
332- expect ( conf . buildIdentifier ) . toEqual ( 'typescript-esm' ) ;
333- } ) ;
315+ it ( 'should resolve forge.config.mts' , async ( ) => {
316+ const fixturePath = path . resolve (
317+ __dirname ,
318+ '../../fixture/dummy_default_mts_conf' ,
319+ ) ;
320+ const conf = await findConfig ( fixturePath ) ;
321+ expect ( conf . buildIdentifier ) . toEqual ( 'typescript-esm' ) ;
334322 } ) ;
335323 } ) ;
336324} ) ;
@@ -366,28 +354,13 @@ describe('forgeConfigIsValidFilePath', () => {
366354 const fixturePath = path . resolve ( __dirname , '../../fixture/dummy_js_conf/' ) ;
367355 await expect (
368356 forgeConfigIsValidFilePath ( fixturePath , 'forge.different.config' ) ,
369- ) . resolves . toEqual ( true ) ;
357+ ) . toEqual ( true ) ;
370358 } ) ;
371359
372360 it ( 'fails when a file is nonexistent' , async ( ) => {
373361 const fixturePath = path . resolve ( __dirname , '../../fixture/dummy_js_conf/' ) ;
374362 await expect (
375363 forgeConfigIsValidFilePath ( fixturePath , 'forge.nonexistent.config' ) ,
376- ) . resolves . toEqual ( false ) ;
377- } ) ;
378- } ) ;
379-
380- describe ( 'renderConfigTemplate' , ( ) => {
381- it ( 'should import a JS file when a string starts with "require:"' , ( ) => {
382- const dir = path . resolve ( __dirname , '../../fixture/dummy_js_conf' ) ;
383- const config = {
384- foo : 'require:foo' ,
385- } ;
386- renderConfigTemplate ( dir , { } , config ) ;
387- expect ( config . foo ) . toEqual ( {
388- bar : {
389- baz : 'quux' ,
390- } ,
391- } ) ;
364+ ) . toEqual ( false ) ;
392365 } ) ;
393366} ) ;
0 commit comments