Skip to content

Options should be the second argument to tap.test. Refs #492 #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions test/bin-watch-serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ function normalize(result) {

var options = { timeout: 1000 * 120 };

test('harness', function (t) {
test('harness', options, function (t) {
var docProcess = documentation(['fixture/simple.input.js', '--serve']);
t.ok(docProcess, 'creates a subprocess object');
docProcess.kill();
t.end();
}, options);
});

test('provides index.html', function (t) {
test('provides index.html', options, function (t) {
var docProcess = documentation(['serve', 'fixture/simple.input.js']);
docProcess.stdout.on('data', function (data) {
t.equal(data.toString().trim(), 'documentation.js serving on port 4001', 'shows listening message');
Expand All @@ -51,9 +51,9 @@ test('provides index.html', function (t) {
t.end();
});
});
}, options);
});

test('accepts port argument', function (t) {
test('accepts port argument', options, function (t) {
var docProcess = documentation(['serve', 'fixture/simple.input.js', '--port=4004']);
docProcess.stdout.on('data', function (data) {
t.equal(data.toString().trim(), 'documentation.js serving on port 4004', 'shows listening message');
Expand All @@ -63,9 +63,9 @@ test('accepts port argument', function (t) {
t.end();
});
});
}, options);
});

test('--watch', function (t) {
test('--watch', options, function (t) {
var tmpFile = path.join(os.tmpdir(), '/simple.js');
fs.writeFileSync(tmpFile, '/** a function */function apples() {}');
var docProcess = documentation(['serve', tmpFile, '--watch']);
Expand All @@ -82,9 +82,9 @@ test('--watch', function (t) {
}, 1000);
});
});
}, options);
});

test('--watch', function (t) {
test('--watch', options, function (t) {
var tmpDir = os.tmpdir();
var a = path.join(tmpDir, '/simple.js');
var b = path.join(tmpDir, '/required.js');
Expand All @@ -104,9 +104,9 @@ test('--watch', function (t) {
}, 1000);
});
});
}, options);
});

test('error page', function (t) {
test('error page', options, function (t) {
var tmpDir = os.tmpdir();
var a = path.join(tmpDir, '/simple.js');
fs.writeFileSync(a, '**');
Expand All @@ -118,4 +118,4 @@ test('error page', function (t) {
t.end();
});
});
}, options);
});
74 changes: 37 additions & 37 deletions test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ function normalize(result) {

var options = { timeout: 1000 * 120 };

test('documentation binary', function (t) {
test('documentation binary', options, function (t) {
documentation(['build fixture/simple.input.js'], function (err, data) {
t.error(err);
t.equal(data.length, 1, 'simple has no dependencies');
t.end();
});
}, options);
});

test('defaults to parsing package.json main', function (t) {
test('defaults to parsing package.json main', options, function (t) {
documentation(['build'], { cwd: path.join(__dirname, '..') }, function (err, data) {
t.error(err);
t.ok(data.length, 'we document ourself');
t.end();
});
}, options);
});

test('polyglot mode', function (t) {
test('polyglot mode', options, function (t) {
documentation(['build fixture/polyglot/blend.cpp --polyglot'],
function (err, data) {
t.ifError(err);
Expand All @@ -78,9 +78,9 @@ test('polyglot mode', function (t) {
'parsed C++ file');
t.end();
});
}, options);
});

test('accepts config file', function (t) {
test('accepts config file', options, function (t) {
documentation(['build fixture/sorting/input.js -c fixture/config.json'],
function (err, data) {
t.error(err);
Expand All @@ -100,9 +100,9 @@ test('accepts config file', function (t) {
'respected sort order from config file');
t.end();
});
}, options);
});

test('accepts config file - reports failures', function (t) {
test('accepts config file - reports failures', options, function (t) {
documentation(['build fixture/sorting/input.js -c fixture/config-bad.yml'], {},
function (err, data, stderr) {
t.error(err);
Expand All @@ -119,15 +119,15 @@ test('accepts config file - reports failures', function (t) {
t.equal(stderr, expected, 'reported a missing toc entry');
t.end();
}, false);
}, options);
});

test('--shallow option', function (t) {
documentation(['build --shallow fixture/internal.input.js'], function (err, data) {
t.error(err);
t.equal(data.length, 0, 'should not check dependencies');
t.end();
});
}, options);
});

test('external modules option', function (t) {
documentation(['build fixture/external.input.js ' +
Expand Down Expand Up @@ -155,21 +155,21 @@ test('extension option', function (t) {
});

test('invalid arguments', function (group) {
group.test('bad -f option', function (t) {
group.test('bad -f option', options, function (t) {
documentation(['build -f DOES-NOT-EXIST fixture/internal.input.js'], function (err) {
t.ok(err, 'returns error');
t.end();
});
}, options);
});

group.test('html with no destination', function (t) {
group.test('html with no destination', options, function (t) {
documentation(['build -f html fixture/internal.input.js'], function (err) {
t.ok(err.toString()
.match(/The HTML output mode requires a destination directory set with -o/),
'needs dest for html');
t.end();
});
}, options);
});

group.test('bad command', function (t) {
documentation(['-f html fixture/internal.input.js'], function (err, stdout, stderr) {
Expand All @@ -182,16 +182,16 @@ test('invalid arguments', function (group) {
group.end();
});

test('--version', function (t) {
test('--version', options, function (t) {
documentation(['--version'], {}, function (err, output) {
t.ok(output, 'outputs version');
t.end();
}, false);
}, options);
});

test('lint command', function (group) {

group.test('generates lint output', function (t) {
group.test('generates lint output', options, function (t) {
documentation(['lint fixture/lint/lint.input.js'], function (err, data) {
var output = path.join(__dirname, 'fixture/lint/lint.output.js');
data = data.toString().split('\n').slice(2).join('\n');
Expand All @@ -202,41 +202,41 @@ test('lint command', function (group) {
t.equal(data, fs.readFileSync(output, 'utf8'), 'outputs lint');
t.end();
});
}, options);
});

group.test('generates no output on a good file', function (t) {
group.test('generates no output on a good file', options, function (t) {
documentation(['lint fixture/simple.input.js'], {}, function (err, data) {
t.equal(err, null);
t.equal(data, '', 'no output');
t.end();
}, false);
}, options);
});

group.test('exposes syntax error on a bad file', function (t) {
group.test('exposes syntax error on a bad file', options, function (t) {
documentation(['lint fixture/bad/syntax.input.js'], {}, function (err, data) {
t.ok(err.code > 0, 'exits with a > 0 exit code');
t.end();
}, false);
}, options);
});

group.end();
});

test('given no files', function (t) {
test('given no files', options, function (t) {
documentation(['build'], function (err) {
t.ok(err.toString()
.match(/documentation was given no files and was not run in a module directory/),
'no files given');
t.end();
});
}, options);
});

test('with an invalid command', function (t) {
test('with an invalid command', options, function (t) {
documentation(['invalid'], function (err) {
t.ok(err, 'returns error');
t.end();
});
}, options);
});

test('--access flag', function (t) {
documentation(['build --shallow fixture/internal.input.js -a public'], {}, function (err, data) {
Expand Down Expand Up @@ -271,7 +271,7 @@ test('--infer-private flag', function (t) {
}, false);
});

test('write to file', function (t) {
test('write to file', options, function (t) {

var dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());

Expand All @@ -281,9 +281,9 @@ test('write to file', function (t) {
t.ok(fs.existsSync(dst), 'created file');
t.end();
}, false);
}, options);
});

test('write to html', function (t) {
test('write to html', options, function (t) {

var dstDir = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
fs.mkdirSync(dstDir);
Expand All @@ -295,9 +295,9 @@ test('write to html', function (t) {
t.ok(fs.existsSync(path.join(dstDir, 'index.html')), 'created index.html');
t.end();
}, false);
}, options);
});

test('write to html with custom theme', function (t) {
test('write to html with custom theme', options, function (t) {

var dstDir = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
fs.mkdirSync(dstDir);
Expand All @@ -309,9 +309,9 @@ test('write to html with custom theme', function (t) {
t.ok(fs.readFileSync(path.join(dstDir, 'index.html'), 'utf8'), 'Hello world');
t.end();
}, false);
}, options);
});

test('write to html, highlightAuto', function (t) {
test('write to html, highlightAuto', options, function (t) {

var fixture = 'fixture/auto_lang_hljs/multilanguage.input.js',
config = 'fixture/auto_lang_hljs/config.yml',
Expand All @@ -331,13 +331,13 @@ test('write to html, highlightAuto', function (t) {
'html is recognized by highlightjs');
t.end();
}, false);
}, options);
});

test('fatal error', function (t) {
test('fatal error', options, function (t) {

documentation(['build --shallow fixture/bad/syntax.input.js'], {},
function (err) {
t.ok(err.toString().match(/Unexpected token/), 'reports syntax error');
t.end();
}, false);
}, options);
});