mirror of
https://github.com/strapi/strapi.git
synced 2025-12-04 11:02:12 +00:00
Merge branch 'main' into patch-1
This commit is contained in:
commit
01eed9f00c
@ -10,6 +10,12 @@ jest.mock('@strapi/typescript-utils', () => ({
|
||||
}));
|
||||
|
||||
describe('getCustomAppConfigFile', () => {
|
||||
test('It should return undefined when the src/admin does no exist', async () => {
|
||||
const result = await getCustomAppConfigFile('/');
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
test('It should return undefined when the app config file extension is not .js and useTypeScript is falsy', async () => {
|
||||
fse.readdir = jest.fn(() => {
|
||||
return ['app.example.js', 'webpack.config.js', 'app.ts', 'app.tsx'];
|
||||
@ -23,6 +29,10 @@ describe('getCustomAppConfigFile', () => {
|
||||
});
|
||||
|
||||
test('It should return app.js when the app config file extension is not (.ts|.tsx) and useTypeScript is truthy', async () => {
|
||||
fse.pathExistsSync = jest.fn(() => {
|
||||
return true;
|
||||
});
|
||||
|
||||
fse.readdir = jest.fn(() => {
|
||||
return ['app.js', 'webpack.config.js', 'app.example.ts', 'app.example.tsx'];
|
||||
});
|
||||
@ -35,6 +45,10 @@ describe('getCustomAppConfigFile', () => {
|
||||
});
|
||||
|
||||
test('It should return app.js when the app config file extension is .js and useTypeScript is falsy', async () => {
|
||||
fse.pathExistsSync = jest.fn(() => {
|
||||
return true;
|
||||
});
|
||||
|
||||
fse.readdir = jest.fn(() => {
|
||||
return ['app.js', 'webpack.config.js', 'app.ts', 'app.tsx'];
|
||||
});
|
||||
|
||||
@ -11,6 +11,11 @@ const { isUsingTypeScript } = require('@strapi/typescript-utils');
|
||||
*/
|
||||
const getCustomAppConfigFile = async (dir) => {
|
||||
const adminSrcPath = join(dir, 'src', 'admin');
|
||||
|
||||
if (!fse.pathExistsSync(adminSrcPath)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const useTypeScript = await isUsingTypeScript(adminSrcPath, 'tsconfig.json');
|
||||
|
||||
const files = await fse.readdir(adminSrcPath);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user