1
+ var path = require ( 'path' ) ;
2
+
1
3
var assert = require ( 'chai' ) . assert ;
2
4
3
5
var chalk = require ( '../lib/chalk' ) ;
@@ -169,6 +171,8 @@ describe('helper', function() {
169
171
} ) ; // #langToCommentStyle
170
172
171
173
describe ( '#dirAndFiles' , function ( ) {
174
+ var root = path . join ( __dirname , '..' ) ;
175
+
172
176
it ( 'should ok' , function ( ) {
173
177
process . env . HOME = '/home/skygragon' ;
174
178
@@ -183,13 +187,27 @@ describe('helper', function() {
183
187
assert . equal ( h . getHomeDir ( ) , 'C:\\Users\\skygragon' ) ;
184
188
} ) ;
185
189
186
- it ( 'should getDirData ok' , function ( ) {
187
- var files = h . getDirData ( [ 'lib' , 'plugins' ] ) ;
190
+ it ( 'should getCodeDir ok' , function ( ) {
191
+ assert . equal ( h . getCodeDir ( ) , root ) ;
192
+ assert . equal ( h . getCodeDir ( '.' ) , root ) ;
193
+ assert . equal ( h . getCodeDir ( 'icons' ) , path . join ( root , 'icons' ) ) ;
194
+ assert . equal ( h . getCodeDir ( 'lib/plugins' ) , path . join ( root , 'lib' , 'plugins' ) ) ;
195
+ } ) ;
196
+
197
+ it ( 'should getCodeDirData ok' , function ( ) {
198
+ var files = h . getCodeDirData ( 'lib/plugins' ) ;
188
199
assert . equal ( files . length , 3 ) ;
189
200
assert . equal ( files [ 0 ] . name , 'cache' ) ;
190
201
assert . equal ( files [ 1 ] . name , 'leetcode' ) ;
191
202
assert . equal ( files [ 2 ] . name , 'retry' ) ;
192
203
} ) ;
204
+
205
+ it ( 'should getPluginFile ok' , function ( ) {
206
+ var expect = path . join ( root , 'lib/plugins/cache.js' ) ;
207
+ assert . equal ( h . getPluginFile ( 'cache.js' ) , expect ) ;
208
+ assert . equal ( h . getPluginFile ( './cache.js' ) , expect ) ;
209
+ assert . equal ( h . getPluginFile ( 'https://github.com/skygragon/cache.js' ) , expect ) ;
210
+ } ) ;
193
211
} ) ; // #dirAndFiles
194
212
195
213
describe ( '#getSetCookieValue' , function ( ) {
0 commit comments