-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
69 lines (56 loc) · 2.24 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
require('mocha');
var assert = require('assert');
var stripColor = require('strip-color');
var Separator = require('./');
describe('Separator', function () {
it('should use the default line', function () {
var sep = new Separator();
assert.equal(stripColor(sep.toString()), '────────');
});
it('should set "type" property to "separator"', function () {
var sep = new Separator();
assert.equal(sep.type, 'separator');
});
it('should render separator.prefix + separator.line', function () {
var sep = new Separator();
assert.equal(sep.render(), ' \u001b[2m────────\u001b[22m\n');
});
it('should support an empty string as separator.line', function () {
var sep = new Separator({line: ''});
assert.equal(sep.render(), ' \n');
});
it('should support an empty string as separator.prefix', function () {
var sep = new Separator({prefix: ''});
assert.equal(sep.render(), '\u001b[2m────────\u001b[22m\n');
});
it('should support passing separator.line as a string', function () {
var sep = new Separator('foo bar');
assert.equal(stripColor(sep.line), 'foo bar');
});
it('should support passing separator.line on an options object', function () {
var sep = new Separator({line: 'foo bar'});
assert.equal(stripColor(sep.line), 'foo bar');
});
it('should use the given prefix', function () {
var sep = new Separator({line: 'foo bar', prefix: '~~~~'});
assert.equal(sep.render(), '~~~~foo bar\n');
});
it('should take an instance of Separator as options', function () {
var foo = new Separator('foo bar');
var bar = new Separator(foo);
assert.equal(stripColor(bar.line), 'foo bar');
});
it('should expose a .toString method for getting separator.line', function () {
var sep = new Separator('foo bar');
assert.equal(stripColor(sep.toString()), 'foo bar');
});
it('instances should be stringified when appended to a string', function () {
var sep = new Separator('foo bar');
assert.equal(stripColor(String(sep)), 'foo bar');
});
it('should expose a helper function to check for separator', function () {
assert(Separator.exclude({}));
assert(!Separator.exclude(new Separator()));
});
});