Skip to content

Commit

Permalink
0.1.3 refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MorganConrad committed Nov 25, 2017
1 parent d4db20d commit 85a4802
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 42 deletions.
74 changes: 37 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
{
"name": "metalsmith-keymaster",
"version": "0.1.2",
"description": "A metalsmith plugin to copy or create file properties, and save under new keys.",
"main": "keymaster.js",
"scripts": {
"test": "nyc --reporter=lcov tape test/test.js",
"coverage" : "nyc --reporter=text-lcov report | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/MorganConrad/metalsmith-keymaster.git"
},
"keywords": [
"metalsmith",
"plugin",
"copy",
"add",
"file",
"values",
"framework"
],
"devDependencies": {
"nyc" : "^11.2.0",
"tape": "^4.6",
"coveralls" : "^3.0"
},
"author": "Morgan Conrad <flyingspaniel@gmail.com> (http://flyingspaniel.com/)",
"contributors": [
"Simon Carpinter (https://simon.carpinter.name/)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/MorganConrad/metalsmith-keymaster/issues"
},
"homepage": "https://github.com/MorganConrad/metalsmith-keymaster#readme"
}
{
"name": "metalsmith-keymaster",
"version": "0.1.3",
"description": "A metalsmith plugin to copy or create file properties, and save under new keys.",
"main": "keymaster.js",
"scripts": {
"test": "nyc --reporter=lcov tape test/test.js",
"coverage": "nyc --reporter=text-lcov report | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/MorganConrad/metalsmith-keymaster.git"
},
"keywords": [
"metalsmith",
"plugin",
"copy",
"add",
"file",
"values",
"framework"
],
"devDependencies": {
"nyc": "^11.2.0",
"tape": "^4.6",
"coveralls": "^3.0"
},
"author": "Morgan Conrad <flyingspaniel@gmail.com> (http://flyingspaniel.com/)",
"contributors": [
"Simon Carpinter (https://simon.carpinter.name/)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/MorganConrad/metalsmith-keymaster/issues"
},
"homepage": "https://github.com/MorganConrad/metalsmith-keymaster#readme"
}
16 changes: 11 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,44 @@ test('filefilter', function(t) {
fileData = files['file2.html']
t.false(fileData.newtitle);
t.true(fileData.copyContents);
t.end();
});


// test user provided function
test('userFnFileFilter', function(t) {
var files = createFiles();
keymaster({
from: '.',
to: 'copyContents',
filter: function(filePath) { return 'file1.md' === filePath}
})(files, null, done);

t.true(files['file1.md'].copyContents);

t.end();
});

test('examples similar to README', function(t) {
test('README excerpt', function(t) {
var files = createFiles();
keymaster({
from: function(data) {
return data.contents.toString().substring(24, 35); // slight change from readme
},
to: 'excerpt'
})(files, null, done);
t.equal(files['file1.md'].excerpt, 'Lorem ipsum');
t.end();
});

test('README add filename', function(t) {
var files = createFiles();
keymaster({
from: function(data, filePath) {
return filePath;
},
to: 'yourKeyHere'
})(files, null, done);

t.equal(files['file1.md'].excerpt, 'Lorem ipsum');
t.equal(files['file2.html'].yourKeyHere, 'file2.html');

t.end();
});

Expand Down

0 comments on commit 85a4802

Please sign in to comment.