From 007adb6a3382239062302f0d44b1c942f81d5fca Mon Sep 17 00:00:00 2001 From: Sam Lord Date: Mon, 27 Feb 2023 16:37:36 +0000 Subject: [PATCH] Prevent tests from erroring when calling validate.init() refs: https://github.com/TryGhost/Toolbox/issues/389 Calling validate always uses the cache system, so this commit makes sure that the cache system is always initialised correctly by the tests. --- .../unit/server/services/themes/validate.test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ghost/core/test/unit/server/services/themes/validate.test.js b/ghost/core/test/unit/server/services/themes/validate.test.js index 6bd6f8d3cf..c231620328 100644 --- a/ghost/core/test/unit/server/services/themes/validate.test.js +++ b/ghost/core/test/unit/server/services/themes/validate.test.js @@ -6,11 +6,13 @@ const list = require('../../../../../core/server/services/themes/list'); const gscan = require('gscan'); const assert = require('assert'); const adapterManager = require('../../../../../core/server/services/adapter-manager'); +const InMemoryCache = require('../../../../../core/server/adapters/cache/Memory'); describe('Themes', function () { let checkZipStub; let checkStub; let formatStub; + let adapterStub; beforeEach(function () { checkZipStub = sinon.stub(gscan, 'checkZip'); @@ -29,6 +31,15 @@ describe('Themes', function () { path: '/path/to/theme' }; + beforeEach(function () { + adapterStub = sinon.stub(adapterManager, 'getAdapter').returns(new InMemoryCache()); + validate.init(); + }); + + afterEach(function () { + adapterStub.restore(); + }); + it('[success] validates a valid zipped theme', function () { checkZipStub.resolves({}); formatStub.returns({results: {error: []}}); @@ -150,7 +161,7 @@ describe('Themes', function () { validate.init(); }); - it('Does an innitial check if not cached yet', async function () { + it('Does an initial check if not cached yet', async function () { checkStub.resolves({}); formatStub.returns({results: {error: [{hello: 'world'}]}});