fix tests

This commit is contained in:
Ben Irvin 2023-03-09 15:02:12 +01:00
parent 0d70c10363
commit 2bc2aaa96e

View File

@ -78,9 +78,11 @@ describe('Transfer', () => {
jest.spyOn(console, 'info').mockImplementation(() => {});
jest.spyOn(console, 'error').mockImplementation(() => {});
const destinationUrl = new URL('http://strapi.com/admin');
const destinationUrl = new URL('http://one.localhost/admin');
const destinationToken = 'test-token';
const sourceUrl = new URL('http://two.localhost/admin');
beforeEach(() => {
jest.clearAllMocks();
});
@ -90,7 +92,19 @@ describe('Transfer', () => {
await transferCommand({ from: undefined, to: undefined });
});
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/at least one source/i));
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/one source/i));
expect(
mockDataTransfer.strapi.providers.createRemoteStrapiDestinationProvider
).not.toHaveBeenCalled();
});
it('exits with error when both --to and --from are provided', async () => {
await expectExit(1, async () => {
await transferCommand({ from: sourceUrl, to: destinationUrl });
});
expect(console.error).toHaveBeenCalledWith(expect.stringMatching(/one source/i));
expect(
mockDataTransfer.strapi.providers.createRemoteStrapiDestinationProvider
@ -142,6 +156,8 @@ describe('Transfer', () => {
});
});
it.todo('uses local Strapi destination when to is not specified');
it('uses restore as the default strategy', async () => {
await expectExit(0, async () => {
await transferCommand({ from: undefined, to: destinationUrl, toToken: destinationToken });