Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootlint.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Rebert <github@chrisrebert.com>2015-11-16 12:55:51 +0300
committerChris Rebert <github@chrisrebert.com>2015-11-16 12:55:51 +0300
commit5bdbfbd09041adad31e294c88941424e828bbdae (patch)
treeaa7310ee3d66086aed3476419a425739feb5953d /test
parentd063bba3656971ccaa207bb3056fd6b5b996bcca (diff)
parent12c21b23e1fa65336a148df07c054ca97fb308ff (diff)
Merge pull request #253 from kkirsche/addCLITests
[X-Ref: #179] Begin adding tests for CLI
Diffstat (limited to 'test')
-rw-r--r--test/cli_test.js85
1 files changed, 85 insertions, 0 deletions
diff --git a/test/cli_test.js b/test/cli_test.js
new file mode 100644
index 0000000..ddddf44
--- /dev/null
+++ b/test/cli_test.js
@@ -0,0 +1,85 @@
+/*eslint-env node */
+/*eslint no-process-env: 0 */
+
+'use strict';
+
+var sinon = require('sinon');
+var rewire = require('rewire');
+var cli = (process.env.BOOTLINT_COV === '1') ? rewire('../src-cov/cli.js') : rewire('../src/cli.js');
+
+/*
+ ======== A Handy Little Nodeunit Reference ========
+ https://github.com/caolan/nodeunit
+
+ Test methods:
+ test.expect(numAssertions)
+ test.done()
+ Test assertions:
+ test.ok(value, [message])
+ test.deepEqual(actual, expected, [message])
+ test.notDeepEqual(actual, expected, [message])
+ test.strictEqual(actual, expected, [message])
+ test.notStrictEqual(actual, expected, [message])
+ test.throws(block, [error], [message])
+ test.doesNotThrow(block, [error], [message])
+ test.ifError(value)
+*/
+var startingDir = process.cwd();
+var oldTTY = null;
+
+function rAfter() {
+ if (process.stdout.write.restore) {
+ process.stdout.write.restore();
+ }
+
+ if (process.stderr.write.restore) {
+ process.stderr.write.restore();
+ }
+}
+
+exports.bootlint = {
+ setUp: function (done) {
+ oldTTY = process.stdin.isTTY;
+
+ sinon.stub(process.stdout, 'write');
+ sinon.stub(process.stderr, 'write');
+ done();
+ },
+ tearDown: function (done) {
+ process.stdin.isTTY = oldTTY;
+ process.chdir(startingDir);
+
+ // If stdin rewrites were not used, restore them here
+ rAfter();
+ done();
+ },
+ 'Disable tags': function (test) {
+ var i = 0;
+
+ sinon.stub(console, 'log', function (message) {
+ switch (i) {
+ case 0: {
+ test.strictEqual(message, '');
+ break;
+ }
+ case 1: {
+ test.strictEqual(message, '0 lint error(s) found across 0 file(s).');
+ break;
+ }
+ }
+
+ i++;
+ });
+
+ cli.__set__('process', {
+ argv: [''],
+ stdin: {
+ isTTY: process.stdin.isTTY
+ }
+ });
+
+ cli();
+
+ test.done();
+ }
+};