1+ var path = require ( 'path' ) ;
2+
13var assert = require ( 'chai' ) . assert ;
24
35var chalk = require ( '../lib/chalk' ) ;
@@ -169,6 +171,8 @@ describe('helper', function() {
169171 } ) ; // #langToCommentStyle
170172
171173 describe ( '#dirAndFiles' , function ( ) {
174+ var root = path . join ( __dirname , '..' ) ;
175+
172176 it ( 'should ok' , function ( ) {
173177 process . env . HOME = '/home/skygragon' ;
174178
@@ -183,13 +187,27 @@ describe('helper', function() {
183187 assert . equal ( h . getHomeDir ( ) , 'C:\\Users\\skygragon' ) ;
184188 } ) ;
185189
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' ) ;
188199 assert . equal ( files . length , 3 ) ;
189200 assert . equal ( files [ 0 ] . name , 'cache' ) ;
190201 assert . equal ( files [ 1 ] . name , 'leetcode' ) ;
191202 assert . equal ( files [ 2 ] . name , 'retry' ) ;
192203 } ) ;
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+ } ) ;
193211 } ) ; // #dirAndFiles
194212
195213 describe ( '#getSetCookieValue' , function ( ) {
0 commit comments