From 920a3aeb4c99e841b66462cced64960b8fa855bb Mon Sep 17 00:00:00 2001 From: Naz Date: Tue, 6 Sep 2022 18:46:32 +0800 Subject: [PATCH] Fixed adapter-related unit test refs https://github.com/TryGhost/Ghost/commit/37dd187fe6c77a42ac00b2e6918d189cf87c3cbd refs https://github.com/TryGhost/Ghost/blob/c36575627daad05849a6c97f00b1adaeb4c8d0a7/ghost/core/core/server/data/importer/handlers/image.js#L16 - The tests were failing because they were stubbing a "generic" adapter, instead of the one which the module under test was using (see referenced code to see what I mean) --- ghost/core/test/unit/server/data/importer/index.test.js | 2 +- ghost/core/test/unit/server/lib/mobiledoc.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ghost/core/test/unit/server/data/importer/index.test.js b/ghost/core/test/unit/server/data/importer/index.test.js index 05e8a77ab7..de457f848c 100644 --- a/ghost/core/test/unit/server/data/importer/index.test.js +++ b/ghost/core/test/unit/server/data/importer/index.test.js @@ -481,7 +481,7 @@ describe('Importer', function () { }); describe('ImageHandler', function () { - const store = storage.getStorage(); + const store = storage.getStorage('images'); it('has the correct interface', function () { ImageHandler.type.should.eql('images'); diff --git a/ghost/core/test/unit/server/lib/mobiledoc.test.js b/ghost/core/test/unit/server/lib/mobiledoc.test.js index ef8582f833..4d789ead0b 100644 --- a/ghost/core/test/unit/server/lib/mobiledoc.test.js +++ b/ghost/core/test/unit/server/lib/mobiledoc.test.js @@ -271,7 +271,7 @@ describe('lib/mobiledoc', function () { }); it('does not render srcsets with incompatible storage engine', function () { - sinon.stub(storage.getStorage(), 'saveRaw').value(null); + sinon.stub(storage.getStorage('images'), 'saveRaw').value(null); let mobiledoc = { version: '0.3.1', @@ -299,11 +299,11 @@ describe('lib/mobiledoc', function () { beforeEach(function () { originalStoragePath = storage.getStorage().storagePath; - storage.getStorage().storagePath = path.join(__dirname, '../../../utils/fixtures/images/'); + storage.getStorage('images').storagePath = path.join(__dirname, '../../../utils/fixtures/images/'); }); afterEach(function () { - storage.getStorage().storagePath = originalStoragePath; + storage.getStorage('images').storagePath = originalStoragePath; }); it('works', async function () {