Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("Can do simple includes with CWD", function(done) {
var index = multiline.stripIndent(function(){/*
Button: {{ inc src="button.html" }}
*/});
var page = crossbow.addPage("index.html", index, {});
var config = {
siteConfig:{},
cwd: "test/fixtures"
};
crossbow.compileOne(page, config, function (err, out) {
if (err) {
done(err);
}
it("can render md blocks with page content", function(done) {
var layout = multiline.stripIndent(function(){/*
{{ content }}
*/});
var index = multiline.stripIndent(function(){/*
---
layout: "default.hbs"
---
{{#md}}
#title
{{/md}}
##Not a title
*/});
crossbow.populateCache("_layouts/default.hbs", layout);
var page = crossbow.addPage("index.html", index, {});
crossbow.compileOne(page, {siteConfig:{}}, function (err, out) {
if (err) {
done(err);
it("Can do simple includes with params", function(done) {
var index = multiline.stripIndent(function(){/*
Button: {{ inc src="button.html" text="Cancel" }}
*/});
crossbow.populateCache("button.html", "<button>{{text}}</button>");
var page = crossbow.addPage("index.html", index, {});
crossbow.compileOne(page, {siteConfig:{}}, function (err, out) {
assert.include(out.compiled, "<button>Cancel</button>");
done();
});
});
it("Can do simple includes with interpolated params in config", function(done) {
it("should loop through and render links to posts in categories", function(done) {
var index = multiline.stripIndent(function(){/*
{{#each categories}}
<p>{{this.title}}</p>
<ul>
{{#each this.items}}
<li>{{this.title}} - {{this.url}}</li>
{{/each}}
</ul>
{{/each}}
*/});
var expected = multiline.stripIndent(function () {/*
<p>javascript</p>
<ul>
<li>Blog 2 - /post2.html</li>
<li>Blog 1 - /post1.html</li>
</ul>
it("replaces {{content}} with page content", function(done) {
var layout = multiline.stripIndent(function(){/*
{{content}}
*/});
var index = multiline.stripIndent(function(){/*
---
layout: "default.hbs"
---
Some content
*/});
crossbow.populateCache("_layouts/default.hbs", layout);
var page = crossbow.addPage("index.html", index, {});
crossbow.compileOne(page, {siteConfig:{}}, function (err, out) {
if (err) {
done(err);
}
assert.equal(out.compiled, "\nSome content\n");
done();
it("Can render with no layout", function (done) {
var post1 = multiline.stripIndent(function () {/*
{{site.sitename}}
*/});
var post = crossbow.addPost("_posts/post2.md", post1, {});
crossbow.compileOne(post, {siteConfig: {sitename: "({shakyShane})"}}, function (err, out) {
var compiled = out.compiled;
assert.include(compiled, "({shakyShane})");
done();
});
});
it("Can render using a default layout in config", function (done) {
it("Does not show any items with published:false in front matter", function() {
var post = multiline.stripIndent(function(){/*
---
layout: test
title: "Homepage"
published: false
---
#{page.title}
*/});
crossbow.addPost("_posts/post1.md", post);
var actual = crossbow.getCache().posts().length;
assert.equal(actual, 0);
});
it("Does not add any items starting with an underscore", function() {
var _ = require("lodash");
var assert = require("chai").assert;
var multiline = require("multiline");
var Post = require("../../../lib/post");
var crossbow = require("../../../index");
var post1 = multiline.stripIndent(function(){/*
---
layout: post-test
---
{{post.date}}
*/});
describe("Creating a Post date from the filename", function(){
beforeEach(function () {
crossbow.clearCache();
crossbow.populateCache("_layouts/post-test.html", "{{ content }}");
});
it("uses date from the filename if not available in front-matter", function() {
it("Can use site variables", function(done) {
var post1 = multiline.stripIndent(function(){/*
---
layout: post-test
title: "Post 1"
date: 2013-11-13
---
Post 1
*/});
var post2 = multiline.stripIndent(function(){/*
---
layout: post-test
title: "Post 2"
date: 2013-11-14
---
it('can parse a multiple <> combinations', function() {
var dsl = multiline.stripIndent(function() {/*
key "value"
key2 "value2"
*/
});
var expected = {key: 'value', key2: 'value2'};
return parser.parseText(dsl).then(function(parsedValue) {
expect(parsedValue).to.deep.equal(expected);
});
});