This commit is contained in:
Ben Irvin 2023-04-06 17:33:04 +02:00
parent 14ec9a67ea
commit 2740ce9831
5 changed files with 18 additions and 18 deletions

View File

@ -90,7 +90,7 @@ describe('Export', () => {
jest.spyOn(console, 'error').mockImplementation(() => {}); jest.spyOn(console, 'error').mockImplementation(() => {});
// Now that everything is mocked, load the 'export' command // Now that everything is mocked, load the 'export' command
const exportCommand = require('../actions/export/action'); const exportAction = require('../actions/export/action');
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
@ -100,7 +100,7 @@ describe('Export', () => {
const filename = 'test'; const filename = 'test';
await expectExit(0, async () => { await expectExit(0, async () => {
await exportCommand({ file: filename }); await exportAction({ file: filename });
}); });
expect(console.error).not.toHaveBeenCalled(); expect(console.error).not.toHaveBeenCalled();
@ -114,7 +114,7 @@ describe('Export', () => {
it('uses default path if not provided by user', async () => { it('uses default path if not provided by user', async () => {
await expectExit(0, async () => { await expectExit(0, async () => {
await exportCommand({}); await exportAction({});
}); });
expect(mockUtils.getDefaultExportName).toHaveBeenCalledTimes(1); expect(mockUtils.getDefaultExportName).toHaveBeenCalledTimes(1);
@ -128,7 +128,7 @@ describe('Export', () => {
it('encrypts the output file if specified', async () => { it('encrypts the output file if specified', async () => {
const encrypt = true; const encrypt = true;
await expectExit(0, async () => { await expectExit(0, async () => {
await exportCommand({ encrypt }); await exportAction({ encrypt });
}); });
expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith( expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith(
@ -142,7 +142,7 @@ describe('Export', () => {
const key = 'secret-key'; const key = 'secret-key';
const encrypt = true; const encrypt = true;
await expectExit(0, async () => { await expectExit(0, async () => {
await exportCommand({ encrypt, key }); await exportAction({ encrypt, key });
}); });
expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith( expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith(
@ -154,7 +154,7 @@ describe('Export', () => {
it('uses compress option', async () => { it('uses compress option', async () => {
await expectExit(0, async () => { await expectExit(0, async () => {
await exportCommand({ compress: false }); await exportAction({ compress: false });
}); });
expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith( expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith(
@ -163,7 +163,7 @@ describe('Export', () => {
}) })
); );
await expectExit(0, async () => { await expectExit(0, async () => {
await exportCommand({ compress: true }); await exportAction({ compress: true });
}); });
expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith( expect(mockDataTransfer.file.providers.createLocalFileDestinationProvider).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({

View File

@ -96,7 +96,7 @@ describe('Import', () => {
jest.spyOn(console, 'error').mockImplementation(() => {}); jest.spyOn(console, 'error').mockImplementation(() => {});
// Now that everything is mocked, load the 'import' command // Now that everything is mocked, load the 'import' command
const importCommand = require('../actions/import/action'); const importAction = require('../actions/import/action');
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks(); jest.clearAllMocks();
@ -112,7 +112,7 @@ describe('Import', () => {
}; };
await expectExit(0, async () => { await expectExit(0, async () => {
await importCommand(options); await importAction(options);
}); });
// strapi options // strapi options

View File

@ -72,7 +72,7 @@ describe('Transfer', () => {
jest.mock('@strapi/data-transfer', () => mockDataTransfer); jest.mock('@strapi/data-transfer', () => mockDataTransfer);
const transferCommand = require('../actions/transfer/action'); const transferAction = require('../actions/transfer/action');
// console spies // console spies
jest.spyOn(console, 'log').mockImplementation(() => {}); jest.spyOn(console, 'log').mockImplementation(() => {});
@ -91,7 +91,7 @@ describe('Transfer', () => {
it('exits with error when no --to or --from is provided', async () => { it('exits with error when no --to or --from is provided', async () => {
await expectExit(1, async () => { await expectExit(1, async () => {
await transferCommand({ from: undefined, to: undefined }); await transferAction({ from: undefined, to: undefined });
}); });
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/one source/i)); expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/one source/i));
@ -103,7 +103,7 @@ describe('Transfer', () => {
it('exits with error when both --to and --from are provided', async () => { it('exits with error when both --to and --from are provided', async () => {
await expectExit(1, async () => { await expectExit(1, async () => {
await transferCommand({ from: sourceUrl, to: destinationUrl }); await transferAction({ from: sourceUrl, to: destinationUrl });
}); });
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/one source/i)); expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/one source/i));
@ -116,7 +116,7 @@ describe('Transfer', () => {
describe('--to', () => { describe('--to', () => {
it('exits with error when auth is not provided', async () => { it('exits with error when auth is not provided', async () => {
await expectExit(1, async () => { await expectExit(1, async () => {
await transferCommand({ from: undefined, to: destinationUrl }); await transferAction({ from: undefined, to: destinationUrl });
}); });
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/missing token/i)); expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/missing token/i));
@ -128,7 +128,7 @@ describe('Transfer', () => {
it('uses destination url and token provided by user', async () => { it('uses destination url and token provided by user', async () => {
await expectExit(0, async () => { await expectExit(0, async () => {
await transferCommand({ from: undefined, to: destinationUrl, toToken: destinationToken }); await transferAction({ from: undefined, to: destinationUrl, toToken: destinationToken });
}); });
expect(console.error).not.toHaveBeenCalled(); expect(console.error).not.toHaveBeenCalled();
@ -147,7 +147,7 @@ describe('Transfer', () => {
it('uses local Strapi source when from is not specified', async () => { it('uses local Strapi source when from is not specified', async () => {
await expectExit(0, async () => { await expectExit(0, async () => {
await transferCommand({ from: undefined, to: destinationUrl, toToken: destinationToken }); await transferAction({ from: undefined, to: destinationUrl, toToken: destinationToken });
}); });
expect(console.error).not.toHaveBeenCalled(); expect(console.error).not.toHaveBeenCalled();
@ -162,7 +162,7 @@ describe('Transfer', () => {
it('uses restore as the default strategy', async () => { it('uses restore as the default strategy', async () => {
await expectExit(0, async () => { await expectExit(0, async () => {
await transferCommand({ from: undefined, to: destinationUrl, toToken: destinationToken }); await transferAction({ from: undefined, to: destinationUrl, toToken: destinationToken });
}); });
expect(console.error).not.toHaveBeenCalled(); expect(console.error).not.toHaveBeenCalled();

View File

@ -11,5 +11,5 @@ module.exports = ({ command }) => {
.command('build') .command('build')
.option('--no-optimization', 'Build the admin app without optimizing assets') .option('--no-optimization', 'Build the admin app without optimizing assets')
.description('Build the strapi admin app') .description('Build the strapi admin app')
.action(getLocalScript('build-action')); // TODO: fix gitignore so that this folder can be called build .action(getLocalScript('build'));
}; };

View File

@ -5,7 +5,7 @@ const { Command } = require('commander');
const availableCommands = [ const availableCommands = [
'admin/create-user', 'admin/create-user',
'admin/reset-user-password', 'admin/reset-user-password',
'build-action', // TODO: this should be 'build' but that is ignored 'build',
'configuration/dump', 'configuration/dump',
'configuration/restore', 'configuration/restore',
'console', 'console',