|
1 | 1 | #!/usr/bin/env node
|
| 2 | + |
2 | 3 | var mockConfig = require('./mock.config.json'),
|
3 | 4 | configParser = require('../lib/config-parser')(mockConfig),
|
4 | 5 | defaultConf = require('../lib/configs/turbo.json'),
|
5 | 6 | shell = require('shelljs'),
|
6 | 7 | helpers = require('./helpers'),
|
7 | 8 | res;
|
8 | 9 |
|
9 |
| -describe('config_parse.js', function () { |
| 10 | +describe('config_parse.js', function() { |
10 | 11 | 'use strict';
|
11 | 12 |
|
12 |
| - beforeEach(function () { |
| 13 | + beforeEach(function() { |
13 | 14 | configParser = require('./../lib/config-parser')(mockConfig);
|
14 | 15 | });
|
15 | 16 |
|
16 |
| - describe('should have defined:', function () { |
17 |
| - it('getTagsFormat', function () { |
| 17 | + describe('should have defined:', function() { |
| 18 | + it('getTagsFormat', function() { |
18 | 19 | expect(configParser.getTagsFormat);
|
19 | 20 | });
|
20 |
| - it('getCommitConf', function () { |
| 21 | + it('getCommitConf', function() { |
21 | 22 | expect(configParser.getCommitConf);
|
22 | 23 | });
|
23 |
| - it('getProperty', function () { |
| 24 | + it('getProperty', function() { |
24 | 25 | expect(configParser.getProperty);
|
25 | 26 | });
|
26 |
| - it('getLogCommand', function () { |
| 27 | + it('getLogCommand', function() { |
27 | 28 | expect(configParser.getLogCommand);
|
28 | 29 | });
|
29 |
| - it('getCommitPromptTex', function () { |
| 30 | + it('getCommitPromptTex', function() { |
30 | 31 | expect(configParser.getCommitPromptText);
|
31 | 32 | });
|
32 |
| - it('getConfigFilesData', function () { |
| 33 | + it('getConfigFilesData', function() { |
33 | 34 | expect(configParser.getConfigFilesData);
|
34 | 35 | });
|
35 | 36 | });
|
36 |
| - describe('getTagsFormat:', function () { |
37 |
| - it('should return an array with elements', function () { |
| 37 | + describe('getTagsFormat:', function() { |
| 38 | + it('should return an array with elements', function() { |
38 | 39 | expect(configParser.getTagsFormat().length).toBeGreaterThan(0);
|
39 | 40 | });
|
40 | 41 | });
|
41 |
| - describe('getCommitConf:', function () { |
42 |
| - it('should return results', function () { |
| 42 | + describe('getCommitConf:', function() { |
| 43 | + it('should return results', function() { |
43 | 44 | expect(configParser.getCommitConf().length).toBeGreaterThan(0);
|
44 | 45 | });
|
45 | 46 | });
|
46 | 47 |
|
47 |
| - describe('getLogCommand:', function () { |
48 |
| - it('should return a string with a command', function () { |
| 48 | + describe('getLogCommand:', function() { |
| 49 | + it('should return a string with a command', function() { |
49 | 50 | expect(typeof configParser.getLogCommand()).toBe('string');
|
50 | 51 | });
|
51 | 52 | });
|
52 | 53 |
|
53 |
| - describe('getCommitPromptText:', function () { |
54 |
| - it('should return false without params', function () { |
| 54 | + describe('getCommitPromptText:', function() { |
| 55 | + it('should return false without params', function() { |
55 | 56 | expect(configParser.getCommitPromptText()).toBeFalsy();
|
56 | 57 | });
|
57 |
| - it('should return false with an unknown prop parameter', function () { |
| 58 | + it('should return false with an unknown prop parameter', function() { |
58 | 59 | expect(configParser.getCommitPromptText('prop212321')).toBeFalsy();
|
59 | 60 | });
|
60 |
| - it('should return false if the prop is set on "" in the conf', function () { |
| 61 | + it('should return false if the prop is set on "" in the conf', function() { |
61 | 62 | mockConfig.turboCommit.textAskDesc = '';
|
62 | 63 | configParser = require('./../lib/config-parser')(mockConfig);
|
63 | 64 | expect(configParser.getCommitPromptText('desc')).toBeFalsy();
|
64 | 65 | });
|
65 |
| - it('should return false if the prop is set on false in the conf', function () { |
| 66 | + it('should return false if the prop is set on false in the conf', function() { |
66 | 67 | mockConfig.turboCommit.textAskDesc = false;
|
67 | 68 | configParser = require('./../lib/config-parser')(mockConfig);
|
68 | 69 | expect(configParser.getCommitPromptText('desc')).toBeFalsy();
|
69 | 70 | });
|
70 |
| - it('should return false if the prop is set on 0 in the conf', function () { |
| 71 | + it('should return false if the prop is set on 0 in the conf', function() { |
71 | 72 | mockConfig.turboCommit.textAskDesc = 0;
|
72 | 73 | configParser = require('./../lib/config-parser')(mockConfig);
|
73 | 74 | expect(configParser.getCommitPromptText('desc')).toBeFalsy();
|
74 | 75 | });
|
75 |
| - it('should retun the string with the right value', function () { |
| 76 | + it('should retun the string with the right value', function() { |
76 | 77 | mockConfig.turboCommit.textAskDesc = 'description here';
|
77 | 78 | configParser = require('./../lib/config-parser')(mockConfig);
|
78 | 79 | expect(configParser.getCommitPromptText('desc')).toBe('description here');
|
79 | 80 | });
|
80 | 81 | });
|
81 | 82 |
|
82 |
| - describe('getProperty:', function () { |
83 |
| - beforeEach(function () { |
84 |
| - spyOn(helpers.mockProcess,'exit'); |
| 83 | + describe('getProperty:', function() { |
| 84 | + beforeEach(function() { |
| 85 | + spyOn(helpers.mockProcess, 'exit'); |
85 | 86 | configParser = require('./../lib/config-parser')(mockConfig, helpers.mockProcess);
|
86 | 87 | });
|
87 | 88 |
|
88 |
| - it('should return results with right param', function () { |
| 89 | + it('should return results with right param', function() { |
89 | 90 | expect(typeof configParser.getProperty('commitConvention')).toBe('object');
|
90 | 91 | });
|
91 |
| - it('should call process.exit(1) without params', function () { |
| 92 | + it('should call process.exit(1) without params', function() { |
92 | 93 | configParser.getProperty();
|
93 | 94 | expect(helpers.mockProcess.exit).toHaveBeenCalledWith(1);
|
94 | 95 | });
|
95 |
| - it('should call process.exit(1) with an unknown property', function () { |
| 96 | + it('should call process.exit(1) with an unknown property', function() { |
96 | 97 | configParser.getProperty('hola-test');
|
97 | 98 | expect(helpers.mockProcess.exit).toHaveBeenCalledWith(1);
|
98 | 99 | });
|
99 |
| - it('should return result with a property that It has boolean value', function () { |
| 100 | + it('should return result with a property that It has boolean value', function() { |
100 | 101 | expect(configParser.getProperty('debug')).toBe(false);
|
101 | 102 | });
|
102 | 103 | });
|
103 | 104 |
|
104 |
| - describe('init:', function () { |
105 |
| - it('should read the default conf without .turbogit', function () { |
| 105 | + describe('init:', function() { |
| 106 | + it('should read the default conf without .turbogit', function() { |
106 | 107 | configParser = require('./../lib/config-parser')();
|
107 | 108 | expect(configParser.getProperty('commitConvention')).toEqual(defaultConf.commitConvention);
|
108 | 109 | });
|
109 | 110 |
|
110 |
| - it('should read the config for the .turbogit file if exists', function () { |
| 111 | + it('should read the config for the .turbogit file if exists', function() { |
111 | 112 | helpers.gitInitInTempFolder();
|
112 | 113 | shell.cat('../test/mock.config.json').to('.turbogit');
|
113 | 114 | configParser = require('./../lib/config-parser')();
|
114 | 115 | expect(configParser.getCommitConf()).toEqual(mockConfig.commitConvention.commitDesc);
|
115 | 116 | helpers.finishTemp();
|
116 | 117 | });
|
117 | 118 | });
|
118 |
| - describe('getConfigFileData:', function () { |
119 |
| - |
120 |
| - beforeEach(function (){ |
| 119 | + describe('getConfigFileData:', function() { |
| 120 | + beforeEach(function() { |
121 | 121 | res = configParser.getConfigFilesData();
|
122 |
| - }) |
| 122 | + }); |
123 | 123 |
|
124 |
| - it('should return an array', function () { |
| 124 | + it('should return an array', function() { |
125 | 125 | expect(res instanceof Array).toBeTruthy();
|
126 | 126 | });
|
127 | 127 |
|
128 |
| - it('should return an array of objects', function () { |
| 128 | + it('should return an array of objects', function() { |
129 | 129 | expect(res[0] instanceof Object).toBeTruthy();
|
130 | 130 | });
|
131 | 131 |
|
132 |
| - it('should return an array of objects with name prop', function () { |
| 132 | + it('should return an array of objects with name prop', function() { |
133 | 133 | expect(res[0].name).toBeDefined();
|
134 | 134 | });
|
135 |
| - it('should return an array of objects with value prop', function () { |
| 135 | + it('should return an array of objects with value prop', function() { |
136 | 136 | expect(res[0].value).toBeDefined();
|
137 | 137 | });
|
138 |
| - it('should return an array of objects with getter prop', function () { |
| 138 | + it('should return an array of objects with getter prop', function() { |
139 | 139 | expect(res[0].getter).toBeDefined();
|
140 | 140 | });
|
141 | 141 |
|
142 |
| - describe('getter props on objects returned:', function () { |
143 |
| - it('should be a function', function () { |
144 |
| - res.forEach( function (obj) { |
| 142 | + describe('getter props on objects returned:', function() { |
| 143 | + it('should be a function', function() { |
| 144 | + res.forEach(function(obj) { |
145 | 145 | expect(obj.getter instanceof Function).toBeTruthy();
|
146 | 146 | });
|
147 | 147 | });
|
148 |
| - it('should return a json on call', function () { |
149 |
| - res.forEach( function (obj) { |
| 148 | + it('should return a json on call', function() { |
| 149 | + res.forEach(function(obj) { |
150 | 150 | expect(obj.getter() instanceof Object).toBeTruthy();
|
151 | 151 | });
|
152 | 152 | });
|
153 |
| - }) |
| 153 | + }); |
154 | 154 | });
|
155 |
| - |
156 | 155 | });
|
0 commit comments