@@ -211,6 +211,46 @@ describe('File', function() {
211211 file . isDirectory ( ) . should . equal ( true ) ;
212212 done ( ) ;
213213 } ) ;
214+
215+ it ( 'returns false when the stats exist but do not contain isDirectory method' , function ( done ) {
216+ var file = new File ( { contents : null , stat : { } } ) ;
217+ file . isDirectory ( ) . should . equal ( false ) ;
218+ done ( ) ;
219+ } ) ;
220+ } ) ;
221+
222+ describe ( 'isSymbolic()' , function ( ) {
223+ var fakeStat = {
224+ isSymbolicLink : function ( ) {
225+ return true ;
226+ } ,
227+ } ;
228+
229+ it ( 'should return false when the contents are a Buffer' , function ( done ) {
230+ var val = new Buffer ( 'test' ) ;
231+ var file = new File ( { contents : val , stat : fakeStat } ) ;
232+ file . isSymbolic ( ) . should . equal ( false ) ;
233+ done ( ) ;
234+ } ) ;
235+
236+ it ( 'should return false when the contents are a Stream' , function ( done ) {
237+ var val = new Stream ( ) ;
238+ var file = new File ( { contents : val , stat : fakeStat } ) ;
239+ file . isSymbolic ( ) . should . equal ( false ) ;
240+ done ( ) ;
241+ } ) ;
242+
243+ it ( 'should return true when the contents are a null' , function ( done ) {
244+ var file = new File ( { contents : null , stat : fakeStat } ) ;
245+ file . isSymbolic ( ) . should . equal ( true ) ;
246+ done ( ) ;
247+ } ) ;
248+
249+ it ( 'returns false when the stats exist but do not contain isSymbolicLink method' , function ( done ) {
250+ var file = new File ( { contents : null , stat : { } } ) ;
251+ file . isSymbolic ( ) . should . equal ( false ) ;
252+ done ( ) ;
253+ } ) ;
214254 } ) ;
215255
216256 describe ( 'clone()' , function ( ) {
@@ -972,4 +1012,45 @@ describe('File', function() {
9721012 } ) . should . throw ( 'path should be string' ) ;
9731013 } ) ;
9741014 } ) ;
1015+
1016+ describe ( 'symlink get/set' , function ( ) {
1017+ it ( 'should return null on get when no symlink' , function ( done ) {
1018+ var file = new File ( ) ;
1019+ var a = file . symlink ;
1020+ should . not . exist ( a ) ;
1021+ done ( ) ;
1022+ } ) ;
1023+
1024+ it ( 'should return the symlink if set' , function ( done ) {
1025+ var file = new File ( {
1026+ symlink : '/test/test.coffee' ,
1027+ } ) ;
1028+ file . symlink . should . equal ( '/test/test.coffee' ) ;
1029+ done ( ) ;
1030+ } ) ;
1031+
1032+ it ( 'should error on set with non-string symlink' , function ( done ) {
1033+ var file = new File ( ) ;
1034+ try {
1035+ file . symlink = null ;
1036+ } catch ( err ) {
1037+ should . exist ( err ) ;
1038+ done ( ) ;
1039+ }
1040+ } ) ;
1041+
1042+ it ( 'should set the symlink' , function ( done ) {
1043+ var file = new File ( ) ;
1044+ file . symlink = '/test/test.coffee' ;
1045+ file . symlink . should . equal ( '/test/test.coffee' ) ;
1046+ done ( ) ;
1047+ } ) ;
1048+
1049+ it ( 'should set the relative symlink' , function ( done ) {
1050+ var file = new File ( ) ;
1051+ file . symlink = './test.coffee' ;
1052+ file . symlink . should . equal ( './test.coffee' ) ;
1053+ done ( ) ;
1054+ } ) ;
1055+ } ) ;
9751056} ) ;
0 commit comments