Permalink
Browse files

Added test for empty file

  • Loading branch information...
davidmerfield committed Jan 9, 2019
1 parent 5e4e195 commit 15a28e7d089ec6830a9f9e41d6581668f3670955
Showing with 27 additions and 14 deletions.
  1. +27 −14 app/build/prepare/tests/index.js
@@ -1,31 +1,44 @@
fdescribe("prepare", function() {
var prepare = require("../index");

var prepare = require('../index');

beforeEach(function(){
beforeEach(function() {
this.entry = {
path: '',
path: "",
size: 123,
html: '',
html: "",
updated: 123,
draft: true,
metadata: {}
};
});


it("returns an empty title, summary and teaser when the file is empty", function(){

// This was the result of a rather niche bug, caused by files like this:
// Title:
// Hello world!
// Blot was generating an empty title *and* an empty empty summary, since
// 'Hello world!' was in the auto-generated title but not the metadata
// title. The summary generated is now passed the metadata title too...
it("includes what would become the title, in the summary, if the title is set to empty in the file's metadata", function() {
var entry = this.entry;

entry.html = '<p>Hey there.</p>';
entry.html = "<p>Hey there.</p>";
entry.metadata = {
title: ''
};
title: ""
};

prepare(entry);

expect(entry.title).toEqual("");
expect(entry.summary).toEqual("Hey there.");
});

it("generates an empty title when given an empty file", function() {
var entry = this.entry;

entry.html = "";

prepare(entry);

expect(entry.title).toEqual('');
expect(entry.summary).toEqual('Hey there.');
expect(entry.title).toEqual("");
});
});
});

0 comments on commit 15a28e7

Please sign in to comment.