-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.js
67 lines (58 loc) · 2.01 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
/*!
* center-align <https://github.com/jonschlinkert/center-align>
*
* Copycenter (c) 2015 Jon Schlinkert.
* Licensed under the MIT license.
*/
'use strict';
require('mocha');
var assert = require('assert');
var centerAlign = require('./');
var fixture = [
'Lorem ipsum dolor sit amet,',
'consectetur adipiscing',
'elit, sed do eiusmod tempor incididunt',
'ut labore et dolore',
'magna aliqua. Ut enim ad minim',
'veniam, quis'
];
var expected = [
' Lorem ipsum dolor sit amet,',
' consectetur adipiscing',
'elit, sed do eiusmod tempor incididunt',
' ut labore et dolore',
' magna aliqua. Ut enim ad minim',
' veniam, quis'
];
describe('center-align', function () {
it('should center align the strings in an array of strings', function () {
assert.deepEqual(centerAlign(fixture), expected);
});
it('should center align a string to the expected width', function () {
assert.deepEqual(centerAlign(fixture, 40), [
' Lorem ipsum dolor sit amet,',
' consectetur adipiscing',
' elit, sed do eiusmod tempor incididunt',
' ut labore et dolore',
' magna aliqua. Ut enim ad minim',
' veniam, quis'
]);
assert.deepEqual(centerAlign(fixture, 50), [
' Lorem ipsum dolor sit amet,',
' consectetur adipiscing',
' elit, sed do eiusmod tempor incididunt',
' ut labore et dolore',
' magna aliqua. Ut enim ad minim',
' veniam, quis'
]);
});
it('should center align a string to the given width', function () {
assert.deepEqual(centerAlign('foo', 9), ' foo ');
assert.deepEqual(centerAlign('foo', 10), ' foo ');
assert.deepEqual(centerAlign('foo', 11), ' foo ');
assert.deepEqual(centerAlign('foo', 12), ' foo ');
});
it('should center align the lines in a string', function () {
assert.equal(centerAlign(fixture.join('\n')), expected.join('\n'));
});
});