mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Un-skipped populateImageSizes subdir test
refs 19c5e94259
- deleting `urlUtils` from the require cache caused problems in later unit tests that were stubbing `urlUtils` because they had required the `urlUtils` instance that existed before it got deleted/re-initialised in this test, so their modules under test ended up using non-stubbed instances
- fix by stubbing the `urlUtils` methods in this test too (we should probably fix this properly at some point so that config changes correctly propagate to `urlUtils` and we don't need to stub internals)
This commit is contained in:
parent
19c5e94259
commit
0d82b3f92e
@ -1,22 +1,15 @@
|
||||
const path = require('path');
|
||||
const should = require('should');
|
||||
const sinon = require('sinon');
|
||||
const nock = require('nock');
|
||||
const configUtils = require('../../utils/configUtils');
|
||||
const mobiledocLib = require('../../../core/server/lib/mobiledoc');
|
||||
const storage = require('../../../core/server/adapters/storage');
|
||||
const urlUtils = require('../../../core/shared/url-utils');
|
||||
|
||||
describe('lib/mobiledoc', function () {
|
||||
beforeEach(function () {
|
||||
configUtils.set('url', 'https://example.com');
|
||||
|
||||
// UrlUtils gets cached with old config data so we need to make sure it's
|
||||
// reloaded when it gets required in modules under test so that our config
|
||||
// changes actually have an effect
|
||||
// TODO: find why this breaks routing tests if they are run after this test
|
||||
// delete require.cache[require.resolve('../../../core/shared/url-utils')];
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
sinon.restore();
|
||||
nock.cleanAll();
|
||||
configUtils.restore();
|
||||
// ensure config changes are reset and picked up by next test
|
||||
@ -158,11 +151,12 @@ describe('lib/mobiledoc', function () {
|
||||
transformed.cards.length.should.equal(4);
|
||||
});
|
||||
|
||||
// TODO: unskip once `delete require.cache` issue above is resolved
|
||||
it.skip('works with subdir', async function () {
|
||||
// images can be stored with and without subdir when a subdir is configured
|
||||
// but storage adapter always needs paths relative to content dir
|
||||
configUtils.set('url', 'http://localhost:2368/subdir/');
|
||||
// images can be stored with and without subdir when a subdir is configured
|
||||
// but storage adapter always needs paths relative to content dir
|
||||
it('works with subdir', async function () {
|
||||
// urlUtils is a class instance and won't pick up changes to config so
|
||||
// it's necessary to stub out the internals used by
|
||||
sinon.stub(urlUtils, 'getSubdir').returns('/subdir');
|
||||
|
||||
let mobiledoc = {
|
||||
cards: [
|
||||
|
Loading…
Reference in New Issue
Block a user