Skip to content

Commit

Permalink
Merge 2cf6fb2 into 1aa2673
Browse files Browse the repository at this point in the history
  • Loading branch information
vesln committed Dec 2, 2013
2 parents 1aa2673 + 2cf6fb2 commit b2af731
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 77 deletions.
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -6,10 +6,10 @@
"main": "./lib/jsmd.js",
"homepage": "https://github.com/vesln/jsmd",
"scripts": {
"test": "mocha test/*.test.js",
"test": "hydro",
"pretest": "jshint .",
"coverage": "istanbul cover ./node_modules/.bin/_mocha test/*.test.js",
"coveralls": "istanbul cover ./node_modules/.bin/_mocha test/*.test.js --report lcovonly && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
"coverage": "istanbul cover ./node_modules/.bin/hydro -- --formatter hydro-silent",
"coveralls": "istanbul cover ./node_modules/.bin/hydro --report lcovonly && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
},
"repository": {
"type": "git",
Expand All @@ -19,12 +19,12 @@
"jsmd": "./bin/jsmd"
},
"devDependencies": {
"mocha": "~1.14.0",
"chai": "~1.8.1",
"jshint": "~2.3.0",
"coveralls": "~2.3.0",
"istanbul": "~0.1.44",
"nixt": "0.0.4"
"nixt": "0.0.4",
"hydro": "latest"
},
"author": "Veselin Todorov <hi@vesln.com>",
"license": "MIT",
Expand Down
56 changes: 24 additions & 32 deletions test/cli.test.js
Expand Up @@ -9,39 +9,31 @@ var app = function() {
.clone();
};

describe('cli', function() {
describe('--version', function() {
it('prints the app version', function(done) {
app()
.stdout(require('../package.json').version)
.run('--version')
.end(done);
});
});
test('--version', function(done) {
app()
.stdout(require('../package.json').version)
.run('--version')
.end(done);
});

describe('--help', function() {
it('prints help', function(done) {
app()
.stdout(/Usage: jsmd <path>/)
.run('--help')
.end(done);
});
});
test('--help', function(done) {
app()
.stdout(/Usage: jsmd <path>/)
.run('--help')
.end(done);
});

describe('main', function() {
it('does not output anything when the verification went good', function(done) {
app()
.stdout('')
.code(0)
.run(fixture('empty'))
.end(done);
});
test('Verification of valid Markdown files', function(done) {
app()
.stdout('')
.code(0)
.run(fixture('empty'))
.end(done);
});

it('exits with 1 when the verification was not ok', function(done) {
app()
.code(1)
.run(fixture('bad'))
.end(done);
});
});
test('Verification of bad Markdown files', function(done) {
app()
.code(1)
.run(fixture('bad'))
.end(done);
});
18 changes: 8 additions & 10 deletions test/compile.test.js
@@ -1,17 +1,15 @@
var fs = require('fs');
var Rewriter = require('../lib/jsmd/rewriter');

describe('jsmd', function() {
it('compiles files as expected', function() {
var base = __dirname + '/compile/';
test('compiles files as expected', function() {
var base = __dirname + '/compile/';

fs.readdirSync(base).forEach(function(file) {
if (!/\.md$/.test(file)) return;
var md = fs.readFileSync(base + file, 'utf8');
new Rewriter(md).compile(function(compiled) {
var expected = fs.readFileSync(base + file.replace(/md$/, 'js'), 'utf8');
compiled.should.eq(expected.trim());
});
fs.readdirSync(base).forEach(function(file) {
if (!/\.md$/.test(file)) return;
var md = fs.readFileSync(base + file, 'utf8');
new Rewriter(md).compile(function(compiled) {
var expected = fs.readFileSync(base + file.replace(/md$/, 'js'), 'utf8');
compiled.should.eq(expected.trim());
});
});
});
2 changes: 1 addition & 1 deletion test/fixtures/require.md
@@ -1,6 +1,6 @@
```js
require('../../package.json');
require('mocha');
require('chai');
false; // => false
false // => false;
```
9 changes: 8 additions & 1 deletion test/support/bootstrap.js → test/hydro.js
Expand Up @@ -9,6 +9,7 @@ var join = require('path').join;
*/

var chai = require('chai');
var hydro = require('hydro');

/**
* Register `should`.
Expand All @@ -30,5 +31,11 @@ chai.Assertion.includeStack = true;
*/

global.fixture = function(extra) {
return join(__dirname, '..', 'fixtures', extra + '.md');
return join(__dirname, 'fixtures', extra + '.md');
};

/**
* Export `hydro`.
*/

global.test = hydro;
50 changes: 24 additions & 26 deletions test/jsmd.test.js
Expand Up @@ -4,39 +4,37 @@ var run = function run(file, fn) {
verifyFile(fixture(file), fn);
};

describe('jsmd', function() {
it('ignores code different than javascript', function(done) {
run('ruby', function(err) {
should.not.exist(err);
done();
});
test('ignores code different than javascript', function(done) {
run('ruby', function(err) {
should.not.exist(err);
done();
});
});

it('ignores line comments that are not assertions', function(done) {
run('line-comments', function(err) {
should.not.exist(err);
done();
});
test('ignores line comments that are not assertions', function(done) {
run('line-comments', function(err) {
should.not.exist(err);
done();
});
});

it('can assert properly', function(done) {
run('assertions', function(err) {
should.not.exist(err);
done();
});
test('can assert properly', function(done) {
run('assertions', function(err) {
should.not.exist(err);
done();
});
});

it('returns an error when the verification was not successful', function(done) {
run('bad', function(err) {
should.exist(err);
done();
});
test('returns an error when the verification was not successful', function(done) {
run('bad', function(err) {
should.exist(err);
done();
});
});

it('can require relative files', function(done) {
run('require', function(err) {
should.not.exist(err);
done();
});
test('can require relative files', function(done) {
run('require', function(err) {
should.not.exist(err);
done();
});
});
2 changes: 0 additions & 2 deletions test/mocha.opts

This file was deleted.

0 comments on commit b2af731

Please sign in to comment.