Skip to content

Commit

Permalink
PICKME: Fix parseConfig conditional lints
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed May 13, 2024
1 parent 57741ee commit 4945d34
Showing 1 changed file with 21 additions and 32 deletions.
53 changes: 21 additions & 32 deletions packages/env/lib/config/test/parse-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
/* eslint-disable jest/no-conditional-expect */
/**
* Internal dependencies
*/
Expand Down Expand Up @@ -319,16 +318,13 @@ describe( 'parseConfig', () => {
it( 'throws when latest WordPress version needed but not found', async () => {
getLatestWordPressVersion.mockResolvedValue( null );

expect.assertions( 1 );
try {
await parseConfig( '/test/gutenberg', '/cache' );
} catch ( error ) {
expect( error ).toEqual(
new ValidationError(
'Could not find the latest WordPress version. There may be a network issue.'
)
);
}
await expect(
parseConfig( '/test/gutenberg', '/cache' )
).rejects.toEqual(
new ValidationError(
'Could not find the latest WordPress version. There may be a network issue.'
)
);
} );

it( 'throws for unknown config options', async () => {
Expand All @@ -346,16 +342,13 @@ describe( 'parseConfig', () => {
throw new Error( 'Invalid File: ' + configFile );
} );

expect.assertions( 1 );
try {
await parseConfig( '/test/gutenberg', '/cache' );
} catch ( error ) {
expect( error ).toEqual(
new ValidationError(
`Invalid /test/gutenberg/.wp-env.json: "test" is not a configuration option.`
)
);
}
await expect(
parseConfig( '/test/gutenberg', '/cache' )
).rejects.toEqual(
new ValidationError(
`Invalid /test/gutenberg/.wp-env.json: "test" is not a configuration option.`
)
);
} );

it( 'throws for root-only config options', async () => {
Expand All @@ -378,16 +371,12 @@ describe( 'parseConfig', () => {
throw new Error( 'Invalid File: ' + configFile );
} );

expect.assertions( 1 );
try {
await parseConfig( '/test/gutenberg', '/cache' );
} catch ( error ) {
expect( error ).toEqual(
new ValidationError(
`Invalid /test/gutenberg/.wp-env.json: "development.env" is not a configuration option.`
)
);
}
await expect(
parseConfig( '/test/gutenberg', '/cache' )
).rejects.toEqual(
new ValidationError(
`Invalid /test/gutenberg/.wp-env.json: "development.env" is not a configuration option.`
)
);
} );
} );
/* eslint-enable jest/no-conditional-expect */

0 comments on commit 4945d34

Please sign in to comment.