Skip to content

Instantly share code, notes, and snippets.

@kazupon
Last active December 10, 2015 13:29
Show Gist options
  • Save kazupon/4441219 to your computer and use it in GitHub Desktop.
Save kazupon/4441219 to your computer and use it in GitHub Desktop.
.DS_Store
node_modules
npm-debug.log
*.swp
'use strict';
module.exports = function (a, b) {
return a + b;
}
'use strict';
var test = require('tape');
var add = require('../lib/add');
/*
* tape little reference
* =====================
*
* reference url
* -------------
* https://github.com/substack/tape
*
* API
* ---
* - test(name, cb)
* - t.plan(n)
* - t.end()
* - t.fail(msg)
* - t.pass(msg)
* - t.skip(msg)
* - t.ok(value, msg)
* Aliases: t.true, t.assert
* - t.notOk(value, msg)
* Aliases: t.false, t.notok
* - t.error(err, msg)
* Aliases: t.ifError, t.ifErr, t.iferror
* - t.equal(a, b, msg)
* Aliases: t.equals, t.isEqual, t.is, t.strictEqual, t.strictEquals
* - t.notEqual(a, b, msg)
* Aliases: t.notEqual, t.notStrictEqual, t.notStrictEquals, t.isNotEqual, t.isNot, t.not, t.doesNotEqual, t.isInequal
* - t.deepEqual(a, b, msg)
* Aliases: t.deepEquals, t.isEquivalent, t.looseEqual, t.looseEquals, t.same
* - t.notDeepEqual(a, b, msg)
* Aliases: t.notEquivalent, t.notDeeply, t.notSame,
* t.isNotDeepEqual, t.isNotDeeply, t.isNotEquivalent, t.isInequivalent
* - t.throws(fn, expected, msg)
* - t.doesNotThrow(fn, expected, msg)
* - t.test(name, cb)
* - var htest = test.createHarness()
*/
test('add', function (t) {
t.same(add(1, 1), 2);
t.end();
});
'use strict';
module.exports = function (grunt) { // (1): exports
// (2): task configuration
grunt.initConfig({
jshint: {
options: {
node: true
},
files: {
src: [ 'Gruntfile.js' ]
}
}
});
// (3): load plugin task(s)
grunt.loadNpmTasks('grunt-contrib-jshint');
// (4): default task(s)
grunt.registerTask('default', [ 'jshint' ]);
};
{
"name": "foo",
"version": "0.0.1",
"description": "this is sample grunt project.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@gist.github.com:4441219.git"
},
"author": "kazupon",
"license": "MIT",
"devDependencies": {
"grunt": "~0.4.0rc4",
"grunt-contrib-jshint": "~0.1.0",
"tape": "~0.1.5"
}
}
{
"test.js": "test/{%= module_name %}.test.js"
}
'use strict';
// Basic template description.
exports.description = 'Create a unit test code file.';
// Template-specific notes to be displayed before question prompts.
exports.notes = 'Please specify the name of the module that is under lib/.';
// Any existing file or directory matching this wildcard will cause a warning.
//exports.warnOn = 'test/*.js';
// The actual init template.
exports.template = function (grunt, init, done) { // (1): exports
init.process({}, [
// (2):
// Prompt for these values.
{
name: 'module_name',
message: 'What is module name ?',
default: '',
warning: 'Should be a module name'
}
], function (err, props) {
// (3):
// Files to copy (and process).
var files = init.filesToCopy(props);
// (4):
// Actually copy (and process) files.
init.copyAndProcess(files, props);
// (5):
// All done!
done();
});
};
'use strict';
var test = require('tape');
var {%= module_name %} = require('../lib/{%= module_name %}');
/*
* tape little reference
* =====================
*
* reference url
* -------------
* https://github.com/substack/tape
*
* API
* ---
* - test(name, cb)
* - t.plan(n)
* - t.end()
* - t.fail(msg)
* - t.pass(msg)
* - t.skip(msg)
* - t.ok(value, msg)
* Aliases: t.true, t.assert
* - t.notOk(value, msg)
* Aliases: t.false, t.notok
* - t.error(err, msg)
* Aliases: t.ifError, t.ifErr, t.iferror
* - t.equal(a, b, msg)
* Aliases: t.equals, t.isEqual, t.is, t.strictEqual, t.strictEquals
* - t.notEqual(a, b, msg)
* Aliases: t.notEqual, t.notStrictEqual, t.notStrictEquals, t.isNotEqual, t.isNot, t.not, t.doesNotEqual, t.isInequal
* - t.deepEqual(a, b, msg)
* Aliases: t.deepEquals, t.isEquivalent, t.looseEqual, t.looseEquals, t.same
* - t.notDeepEqual(a, b, msg)
* Aliases: t.notEquivalent, t.notDeeply, t.notSame,
* t.isNotDeepEqual, t.isNotDeeply, t.isNotEquivalent, t.isInequivalent
* - t.throws(fn, expected, msg)
* - t.doesNotThrow(fn, expected, msg)
* - t.test(name, cb)
* - var htest = test.createHarness()
*/
test('{%= module_name %}', function (t) {
t.fail('should be implemnted test !!');
t.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment