From 3069f5f5a9db32b3ff3ec15504b46a3f5bc5bee1 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 19 Jun 2019 07:56:30 +0100 Subject: [PATCH] Mocked network access for {{amp_content}} img unit test (#10792) no issue - unit test was fetching images over the network which could cause random test failures on poor connections --- core/test/unit/apps/amp/amp_content_spec.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/test/unit/apps/amp/amp_content_spec.js b/core/test/unit/apps/amp/amp_content_spec.js index a47d1ed435..8d4930ff78 100644 --- a/core/test/unit/apps/amp/amp_content_spec.js +++ b/core/test/unit/apps/amp/amp_content_spec.js @@ -1,5 +1,6 @@ var should = require('should'), rewire = require('rewire'), + nock = require('nock'), urlUtils = require('../../../../test/utils/urlUtils'), ampContentHelper = rewire('../../../../server/apps/amp/lib/helpers/amp_content'); @@ -117,12 +118,18 @@ describe('{{amp_content}} helper', function () { }); it('can transform img tags to amp-img', function (done) { + const GIF1x1 = Buffer.from('R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', 'base64'); + + nock('https://blog.ghost.org') + .get('/content/images/2019/06/test.jpg') + .reply(200, GIF1x1); + var testData = { - html: 'The Ghost Logo', + html: 'The Ghost Logo', updated_at: 'Wed Jul 27 2016 18:17:22 GMT+0200 (CEST)', id: 1 }, - expectedResult = '', + expectedResult = '', ampResult = ampContentHelper.call(testData); ampResult.then(function (rendered) {