123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- var concat = require('concat-stream');
- var tap = require('tap');
- var tape = require('../');
-
- // Exploratory test to ascertain proper output when no t.comment() call
- // is made.
- tap.test('no comment', function (assert) {
- assert.plan(1);
-
- var verify = function (output) {
- assert.equal(output.toString('utf8'), [
- 'TAP version 13',
- '# no comment',
- '',
- '1..0',
- '# tests 0',
- '# pass 0',
- '',
- '# ok',
- ''
- ].join('\n'));
- };
-
- var test = tape.createHarness();
- test.createStream().pipe(concat(verify));
- test('no comment', function (t) {
- t.end();
- });
- });
-
- // Exploratory test, can we call t.comment() passing nothing?
- tap.test('missing argument', function (assert) {
- assert.plan(1);
- var test = tape.createHarness();
- test.createStream();
- test('missing argument', function (t) {
- try {
- t.comment();
- t.end();
- } catch (err) {
- assert.equal(err.constructor, TypeError);
- } finally {
- assert.end();
- }
- });
- });
-
- // Exploratory test, can we call t.comment() passing nothing?
- tap.test('null argument', function (assert) {
- assert.plan(1);
- var test = tape.createHarness();
- test.createStream();
- test('null argument', function (t) {
- try {
- t.comment(null);
- t.end();
- } catch (err) {
- assert.equal(err.constructor, TypeError);
- } finally {
- assert.end();
- }
- });
- });
-
-
- // Exploratory test, how is whitespace treated?
- tap.test('whitespace', function (assert) {
- assert.plan(1);
-
- var verify = function (output) {
- assert.equal(output.toString('utf8'), [
- 'TAP version 13',
- '# whitespace',
- '# ',
- '# a',
- '# a',
- '# a',
- '',
- '1..0',
- '# tests 0',
- '# pass 0',
- '',
- '# ok',
- ''
- ].join('\n'));
- };
-
- var test = tape.createHarness();
- test.createStream().pipe(concat(verify));
- test('whitespace', function (t) {
- t.comment(' ');
- t.comment(' a');
- t.comment('a ');
- t.comment(' a ');
- t.end();
- });
- });
-
- // Exploratory test, how about passing types other than strings?
- tap.test('non-string types', function (assert) {
- assert.plan(1);
-
- var verify = function (output) {
- assert.equal(output.toString('utf8'), [
- 'TAP version 13',
- '# non-string types',
- '# true',
- '# false',
- '# 42',
- '# 6.66',
- '# [object Object]',
- '# [object Object]',
- '# [object Object]',
- '# function ConstructorFunction() {}',
- '',
- '1..0',
- '# tests 0',
- '# pass 0',
- '',
- '# ok',
- ''
- ].join('\n'));
- };
-
- var test = tape.createHarness();
- test.createStream().pipe(concat(verify));
- test('non-string types', function (t) {
- t.comment(true);
- t.comment(false);
- t.comment(42);
- t.comment(6.66);
- t.comment({});
- t.comment({"answer": 42});
- function ConstructorFunction() {}
- t.comment(new ConstructorFunction());
- t.comment(ConstructorFunction);
- t.end();
- });
- });
-
- tap.test('multiline string', function (assert) {
- assert.plan(1);
-
- var verify = function (output) {
- assert.equal(output.toString('utf8'), [
- 'TAP version 13',
- '# multiline strings',
- '# a',
- '# b',
- '# c',
- '# d',
- '',
- '1..0',
- '# tests 0',
- '# pass 0',
- '',
- '# ok',
- ''
- ].join('\n'));
- };
-
- var test = tape.createHarness();
- test.createStream().pipe(concat(verify));
- test('multiline strings', function (t) {
- t.comment([
- 'a',
- 'b',
- ].join('\n'));
- t.comment([
- 'c',
- 'd',
- ].join('\r\n'));
- t.end();
- });
- });
|