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

View File

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

View File

@ -72,7 +72,7 @@ describe('Transfer', () => {
jest.mock('@strapi/data-transfer', () => mockDataTransfer);
const transferCommand = require('../actions/transfer/action');
const transferAction = require('../actions/transfer/action');
// console spies
jest.spyOn(console, 'log').mockImplementation(() => {});
@ -91,7 +91,7 @@ describe('Transfer', () => {
it('exits with error when no --to or --from is provided', 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));
@ -103,7 +103,7 @@ describe('Transfer', () => {
it('exits with error when both --to and --from are provided', 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));
@ -116,7 +116,7 @@ describe('Transfer', () => {
describe('--to', () => {
it('exits with error when auth is not provided', 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));
@ -128,7 +128,7 @@ describe('Transfer', () => {
it('uses destination url and token provided by user', 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();
@ -147,7 +147,7 @@ describe('Transfer', () => {
it('uses local Strapi source when from is not specified', 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();
@ -162,7 +162,7 @@ describe('Transfer', () => {
it('uses restore as the default strategy', 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();

View File

@ -11,5 +11,5 @@ module.exports = ({ command }) => {
.command('build')
.option('--no-optimization', 'Build the admin app without optimizing assets')
.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 = [
'admin/create-user',
'admin/reset-user-password',
'build-action', // TODO: this should be 'build' but that is ignored
'build',
'configuration/dump',
'configuration/restore',
'console',