Skip to content

Commit

Permalink
Add tests for nested and deep-nested path
Browse files Browse the repository at this point in the history
  • Loading branch information
thangngoc89 committed Nov 24, 2015
1 parent c9cf34a commit e525a11
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ function plugin(opts){
return function(files, metalsmith, done){
var metadata = metalsmith.metadata();
var exts = Object.keys(parsers);

for (var key in opts) {
var file = opts[key].replace(/(\/|\\)/g, path.sep);
var ext = extname(file);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/deep-nested/src/path/path/data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string: 'string'
1 change: 1 addition & 0 deletions test/fixtures/nested/src/path/data.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
string: 'string'
30 changes: 30 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,34 @@ describe('metalsmith-metadata', function(){
done();
});
});

it('should parse nested path', function(done){
var m = Metalsmith('test/fixtures/nested').use(metadata({ file: 'path/data.yaml' }));
m.build(function(err){
if (err) return done(err);
assert.deepEqual(m.metadata().file, { string: 'string' });
assert(!exists('test/fixtures/nested/build'));
done();
});
});

it('should parse nested path with backslash', function(done){
var m = Metalsmith('test/fixtures/nested').use(metadata({ file: 'path\\data.yaml' }));
m.build(function(err){
if (err) return done(err);
assert.deepEqual(m.metadata().file, { string: 'string' });
assert(!exists('test/fixtures/nested/build'));
done();
});
});

it('should parse deep nested path', function(done){
var m = Metalsmith('test/fixtures/deep-nested').use(metadata({ file: 'path/path/data.yaml' }));
m.build(function(err){
if (err) return done(err);
assert.deepEqual(m.metadata().file, { string: 'string' });
assert(!exists('test/fixtures/deep-nested/build'));
done();
});
});
});

0 comments on commit e525a11

Please sign in to comment.