Add tests (mainly failing) for #markdown

This commit is contained in:
Avital Oliver
2013-12-23 20:08:59 -08:00
parent 7f855b11f4
commit 5b017ece38
4 changed files with 148 additions and 0 deletions

View File

@@ -13,3 +13,7 @@ Package.on_use(function (api) {
api.use("ui", "client", {weak: true});
api.add_files('template-integration.js', 'client');
});
Package.on_test(function (api) {
api.use("ui", "client");
});

View File

@@ -10,6 +10,7 @@ Package.on_test(function (api) {
api.use('tinytest');
api.use('jquery');
api.use('test-helpers');
api.use('showdown');
api.use('templating', 'client');
api.add_files([

View File

@@ -286,3 +286,94 @@
{{this}}
{{/with}}
</template>
<template name="spacebars_template_test_markdown_basic">
{{#markdown}}
{{hi}}
/each}}
<b>{{hi}}</b>
<b>/each}}</b>
* {{hi}}
* /each}}</b>
* <b>{{hi}}</b>
* <b>/each}}</b>
{{hi}}
/each}}
<b>{{hi}}</b>
<b>/each</b>
&gt
* &gt
`&gt`
&gt
&gt;
* &gt;
`&gt;`
&gt;
`{{hi}}`
`/each}}`
`<b>{{hi}}</b>`
`<b>/each}}`
{{/markdown}}
</template>
<template name="spacebars_template_test_markdown_if">
{{#markdown}}
{{#if cond}}true{{else}}false{{/if}}
<b>{{#if cond}}true{{else}}false{{/if}}</b>
* {{#if cond}}true{{else}}false{{/if}}
* <b>{{#if cond}}true{{else}}false{{/if}}</b>
{{#if cond}}true{{else}}false{{/if}}
<b>{{#if cond}}true{{else}}false{{/if}}</b>
`{{#if cond}}true{{else}}false{{/if}}`
`<b>{{#if cond}}true{{else}}false{{/if}}</b>`
{{/markdown}}
</template>
<template name="spacebars_template_test_markdown_each">
{{#markdown}}
{{#each seq}}{{.}}{{/each}}
<b>{{#each seq}}{{.}}{{/each}}</b>
* {{#each seq}}{{.}}{{/each}}
* <b>{{#each seq}}{{.}}{{/each}}</b>
{{#each seq}}{{.}}{{/each}}
<b>{{#each seq}}{{.}}{{/each}}</b>
`{{#each seq}}{{.}}{{/each}}`
`<b>{{#each seq}}{{.}}{{/each}}</b>`
{{/markdown}}
</template>
<template name="spacebars_template_test_markdown_inclusion">
{{#markdown}}
{{> spacebars_template_test_markdown_inclusion_subtmpl}}
{{/markdown}}
</template>
<template name="spacebars_template_test_markdown_inclusion_subtmpl">
Nothing in particular
</template>
<template name="spacebars_template_test_markdown_block_helpers">
{{#markdown}}
{{#spacebars_template_test_just_content}}
Hi there!
{{/spacebars_template_test_just_content}}
{{/markdown}}
</template>
<template name="spacebars_template_test_just_content">
{{> content}}
</template>

View File

@@ -930,3 +930,55 @@ Tinytest.add('spacebars - templates - constant #each argument', function (test)
test.equal(trim(stripComments(div.innerHTML)).replace(/\s+/g, ' '),
'foo bar 2');
});
// @returns {String} simplified html content
var divContentForMarkdown = function (div) {
return trim(stripComments(div.innerHTML))
.replace(/\<br\>/g, '\n');
};
Tinytest.add('spacebars - templates - #markdown - basic', function (test) {
var tmpl = Template.spacebars_template_test_markdown_basic;
tmpl.hi = function () {
return "<i>hi</i>";
};
var div = renderToDiv(tmpl);
test.equal(divContentForMarkdown(div), "FIXME");
});
Tinytest.add('spacebars - templates - #markdown - if', function (test) {
var tmpl = Template.spacebars_template_test_markdown_if;
var R = new ReactiveVar(false);
tmpl.cond = function () { return R.get(); };
var div = renderToDiv(tmpl);
test.equal(divContentForMarkdown(div), "FIXME(false)");
R.set(true);
Deps.flush();
test.equal(divContentForMarkdown(div), "FIXME(true)");
});
Tinytest.add('spacebars - templates - #markdown - each', function (test) {
var tmpl = Template.spacebars_template_test_markdown_each;
var R = new ReactiveVar([]);
tmpl.seq = function () { return R.get(); };
var div = renderToDiv(tmpl);
test.equal(divContentForMarkdown(div), "FIXME([])");
R.set(["item"]);
Deps.flush();
test.equal(divContentForMarkdown(div), "FIXME([\"item\"])");
});
Tinytest.add('spacebars - templates - #markdown - inclusion', function (test) {
var tmpl = Template.spacebars_template_test_markdown_inclusion;
var div = renderToDiv(tmpl);
test.equal(divContentForMarkdown(div), "<p>Nothing in particular</p>");
});
Tinytest.add('spacebars - templates - #markdown - block helpers', function (test) {
var tmpl = Template.spacebars_template_test_markdown_block_helpers;
var div = renderToDiv(tmpl);
test.equal(divContentForMarkdown(div), "<p>Hi there!</p>");
});