-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathspec.js
31 lines (30 loc) · 995 Bytes
/
spec.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
const wrap = require('.');
describe('string-wrap', () => {
it('Should wrap a string with things', () => {
expect(wrap('hello', '[', ']')).to.equal('[hello]');
});
it('Should use "start" for "end" default', () => {
expect(wrap('hello', '"')).to.equal('"hello"');
});
it('Should default to wrap with nothing', () => {
expect(wrap('hello')).to.equal('hello');
});
it('Should convert input to string', () => {
expect(wrap(1)).to.be.a('string');
expect(wrap(null)).to.be.a('string');
expect(wrap()).to.be.a('string');
});
it('Should convert input to string', () => {
expect(wrap(1)).to.be.a('string');
expect(wrap(/\w/)).to.be.a('string');
expect(wrap({})).to.be.a('string');
expect(wrap(new Set())).to.be.a('string');
expect(wrap(null)).to.be.a('string');
expect(wrap()).to.be.a('string');
});
it('Should treat undefined and null as nothing', () => {
expect(wrap(null)).to.be.empty;
expect(wrap(undefined)).to.be.empty;
expect(wrap()).to.be.empty;
});
});