Skip to content

Commit

Permalink
Added tests for new glob feature for partial search
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Gleitze committed Aug 21, 2015
1 parent 2c4fdfc commit 23bfbf4
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Gruntfile.js
Expand Up @@ -193,6 +193,30 @@ module.exports = function(grunt) {
dest: 'tmp/hello_partial_function.html'}
]
},
partials_glob_df: { // glob expansion partial search (like partials_dfprefixes)
options: {
directory: 'test/fixtures/partials/',
glob: 'sub-$1/pre_$2.mustache',
clear_cache: true
},
files: [
{data: 'test/fixtures/objects/hello_world.json',
template: 'test/fixtures/templates/hello_partial_dir.mustache',
dest: 'tmp/hello_partial_globdf.html'}
]
},
partials_glob: {
options: {
directory: 'test/fixtures/partials/',
glob: '{sub-$1,.}/$2.!(ms)',
clear_cache: true
},
files: [
{data: 'test/fixtures/objects/hello_world.json',
template: 'test/fixtures/templates/hello_partial_glob.mustache',
dest: 'tmp/hello_partial_glob.html'}
]
},
batch_single_template_multiple_json_via_map: {
options: {
template: 'test/fixtures/templates/hello_world.html.mustache'
Expand Down
12 changes: 12 additions & 0 deletions test/expected/hello_glob.html
@@ -0,0 +1,12 @@
<html>
<head>
<meta charset="UTF-8">
<title>A partial</title>
</head>
<body>
<h1>Hello mustache with glob patterns!</h1>
Hello glob pattern!
You can use any file extension :)

</body>
</html>
1 change: 1 addition & 0 deletions test/fixtures/partials/sub-b/another.fancy
@@ -0,0 +1 @@
use any file extension :)
1 change: 1 addition & 0 deletions test/fixtures/partials/sub-b/hello.ext
@@ -0,0 +1 @@
Hello glob pattern!
7 changes: 7 additions & 0 deletions test/fixtures/templates/hello_partial_glob.mustache
@@ -0,0 +1,7 @@
{{> head}}
<body>
<h1>Hello mustache with glob patterns!</h1>
{{> b/hello}}
You can {{> b/another}}
</body>
</html>
22 changes: 22 additions & 0 deletions test/mustache_render_test.js
Expand Up @@ -203,6 +203,28 @@ exports.mustache_render = {
test.done();
},

partials_glob_df: function(test) { // glob expansion partial search (like dfprefixes)
test.expect(1);

var actual = grunt.file.read('tmp/hello_partial_globdf.html');
var expected = grunt.file.read('test/expected/hello_dfprefixes.html');
test.equal(actual, expected, 'should find partials w/ glob ' +
'"sub-$1/pre_$2.mustache".');

test.done();
},

partials_glob: function(test) { // glob expansion partial search
test.expect(1);

var actual = grunt.file.read('tmp/hello_partial_glob.html');
var expected = grunt.file.read('test/expected/hello_glob.html');
test.equal(actual, expected, 'should find partials w/ glob ' +
'"?(+sub-$1)/$2.*".');

test.done();
},

batch_single_template_multiple_json_via_map: function(test) {
test.expect(3);

Expand Down

0 comments on commit 23bfbf4

Please sign in to comment.