diff --git a/core/server/apps/amp/lib/helpers/amp_content.js b/core/server/apps/amp/lib/helpers/amp_content.js
index ebd3bad667..1724f6c143 100644
--- a/core/server/apps/amp/lib/helpers/amp_content.js
+++ b/core/server/apps/amp/lib/helpers/amp_content.js
@@ -126,7 +126,7 @@ function getAmperizeHTML(html, post) {
amperize.parse(html, function (err, res) {
if (err) {
if (err.src) {
- errors.logError(err.message, 'AMP HTML couldn\'t get parsed:' + err.src);
+ errors.logError(err.message, 'AMP HTML couldn\'t get parsed: ' + err.src);
} else {
errors.logError(err);
}
diff --git a/core/server/apps/amp/tests/amp_content_spec.js b/core/server/apps/amp/tests/amp_content_spec.js
index e9fae91ac9..9801a1c1ff 100644
--- a/core/server/apps/amp/tests/amp_content_spec.js
+++ b/core/server/apps/amp/tests/amp_content_spec.js
@@ -5,6 +5,8 @@ var should = require('should'),
// Stuff we are testing
ampContentHelper = rewire('../lib/helpers/amp_content');
+// TODO: Amperize really needs to get stubbed, so we can test returning errors
+// properly and make this test faster!
describe('{{amp_content}} helper', function () {
afterEach(function () {
ampContentHelper.__set__('amperizeCache', {});
@@ -109,7 +111,7 @@ describe('{{amp_content}} helper', function () {
describe('Transforms and sanitizes HTML', function () {
beforeEach(function () {
- configUtils.set({url: 'https://my-awesome-blog.com/'});
+ configUtils.set({url: 'https://blog.ghost.org/'});
});
afterEach(function () {
@@ -119,11 +121,11 @@ describe('{{amp_content}} helper', function () {
it('can transform img tags to amp-img', function (done) {
var testData = {
- html: '',
+ html: '',
updated_at: 'Wed Jul 27 2016 18:17:22 GMT+0200 (CEST)',
id: 1
},
- expectedResult = '
Hello
' + 'Name: | ' + 'Bill Gates | |
---|---|---|
Telephone: | ' + @@ -215,7 +217,7 @@ describe('{{amp_content}} helper', function () { }).catch(done); }); - it('can handle incomplete HTML tags', function (done) { + it('can handle incomplete HTML tags by returning not Amperized HTML', function (done) { var testData = { html: '//img>', updated_at: 'Wed Jul 27 2016 18:17:22 GMT+0200 (CEST)', @@ -238,6 +240,29 @@ describe('{{amp_content}} helper', function () { }).catch(done); }); + it('can handle not existing img src by returning not Amperized HTML', function (done) { + var testData = { + html: '', + updated_at: 'Wed Jul 27 2016 18:17:22 GMT+0200 (CEST)', + id: 1 + }, + ampResult = ampContentHelper.call(testData), + sanitizedHTML, + ampedHTML; + + ampResult.then(function (rendered) { + sanitizedHTML = ampContentHelper.__get__('cleanHTML'); + ampedHTML = ampContentHelper.__get__('ampHTML'); + should.exist(rendered); + rendered.string.should.equal(''); + should.exist(ampedHTML); + ampedHTML.should.be.equal(''); + should.exist(sanitizedHTML); + sanitizedHTML.should.be.equal(''); + done(); + }).catch(done); + }); + it('sanitizes remaining and not valid tags', function (done) { var testData = { html: '' + diff --git a/package.json b/package.json index ea583cb755..f529fb492f 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "node": "~0.10.0 || ~0.12.0 || ^4.2.0" }, "dependencies": { - "amperize": "https://github.com/AileenCGN/amperize/tarball/error-handling-on-timeout", + "amperize": "0.3.1", "archiver": "1.0.1", "bcryptjs": "2.3.0", "bluebird": "3.4.1",