From 2bc2aaa96ea5ce8e79a05f64d65e322cb5f9bc81 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Thu, 9 Mar 2023 15:02:12 +0100 Subject: [PATCH] fix tests --- .../__tests__/data-transfer/transfer.test.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/core/strapi/lib/commands/__tests__/data-transfer/transfer.test.js b/packages/core/strapi/lib/commands/__tests__/data-transfer/transfer.test.js index 2ce6a78722..c63ec54a67 100644 --- a/packages/core/strapi/lib/commands/__tests__/data-transfer/transfer.test.js +++ b/packages/core/strapi/lib/commands/__tests__/data-transfer/transfer.test.js @@ -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 });