forked from github-tools/github-release-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
43 lines (35 loc) · 1.72 KB
/
utils.js
File metadata and controls
43 lines (35 loc) · 1.72 KB
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
'use strict';
var utils = require('../src/utils');
exports['utils'] = {
'Should return the string of the formatted date': function (test) {
test.expect(1);
test.deepEqual(utils.formatDate(new Date(0)), '01/01/1970', 'Given a date object.');
test.done();
},
'Should return the options in a key/value format': function (test) {
test.expect(1);
let bashOptions = utils.getBashOptions([null, null, '--key=value', '--key2=value2']);
test.deepEqual(JSON.stringify(bashOptions), JSON.stringify({
key: 'value',
key2: 'value2'
}), 'Given an array of node arguments.');
test.done();
},
'Should return a camelCase string': function (test) {
test.expect(2);
test.deepEqual(utils.dashToCamelCase('this-is-a-string'), 'thisIsAString', 'Given a string with dashes.');
test.deepEqual(utils.dashToCamelCase('tHIs-Is-a-sTriNg'), 'thisIsAString', 'Given a string with random capital letters');
test.done();
},
'Should return if a number is in between a range': function (test) {
test.expect(7);
test.deepEqual(utils.isInRange(2, 1, 3), true, 'Given a number in range');
test.deepEqual(utils.isInRange(1, 2, 3), false, 'Given a number below range');
test.deepEqual(utils.isInRange(4, 1, 3), false, 'Given a number above range');
test.deepEqual(utils.isInRange(-1, 1, 3), false, 'Given a number above range, negative');
test.deepEqual(utils.isInRange(-1, -3, 0), true, 'Given a number in range, negative');
test.deepEqual(utils.isInRange(2, 2, 5), true, 'Given same number as first range value');
test.deepEqual(utils.isInRange(5, 2, 5), false, 'Given same number as last range value');
test.done();
}
};