import * as assert from 'assert' ; import * as path from 'path' ; import { isPathEqual , isSubpath } from '../extension.bundle' ; suite ( 'fsUtils' , ( ) => { test ( 'isPathEqual, posix, true' , ( ) => { let fsPath1 = '/test/' ; let fsPath2 = '/test/' ; assert . equal ( isPathEqual ( fsPath1 , fsPath2 , path . posix . relative ) , true ) ; fsPath1 = '/test/' ; fsPath2 = '/test' ; assert . equal ( isPathEqual ( fsPath1 , fsPath2 , path . posix . relative ) , true ) ; assert . equal ( isPathEqual ( fsPath2 , fsPath1 , path . posix . relative ) , true ) ; } ) ; test ( 'isPathEqual, win32, true' , ( ) => { let fsPath1 = 'C:\\test\\' ; let fsPath2 = 'C:\\test\\' ; fsPath1 = 'C:\\test\\' ; fsPath2 = 'C:\\test' ; assert . equal ( isPathEqual ( fsPath1 , fsPath2 , path . win32 . relative ) , true ) ; assert . equal ( isPathEqual ( fsPath2 , fsPath1 , path . win32 . relative ) , true ) ; fsPath1 = 'C:\\test\\' ; fsPath2 = 'c:\\TEST\\' ; assert . equal ( isPathEqual ( fsPath1 , fsPath2 , path . win32 . relative ) , true ) ; } ) ; test ( 'isPathEqual, posix, false' , ( ) => { let fsPath1 = '/test/' ; let fsPath2 = '/test/a' ; assert . equal ( isPathEqual ( fsPath1 , fsPath2 , path . posix . relative ) , false ) ; assert . equal ( isPathEqual ( fsPath2 , fsPath1 , path . posix . relative ) , false ) ; fsPath1 = '/test/sub' ; fsPath2 = '/test2/sub2' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . posix . relative ) , false ) ; } ) ; test ( 'isPathEqual, win32, false' , ( ) => { let fsPath1 = 'C:\\test\\a' ; let fsPath2 = 'C:\\test\\' ; assert . equal ( isPathEqual ( fsPath1 , fsPath2 , path . win32 . relative ) , false ) ; assert . equal ( isPathEqual ( fsPath2 , fsPath1 , path . win32 . relative ) , false ) ; fsPath1 = 'C:\\test\\sub' ; fsPath2 = 'D:\\test2\\sub2' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . win32 . relative ) , false ) ; } ) ; test ( 'isSubpath, posix, true' , ( ) => { let fsPath1 = '/test/' ; let fsPath2 = '/test/sub' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . posix . relative ) , true ) ; fsPath1 = '/test/' ; fsPath2 = '/test/sub2/sub2' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . posix . relative ) , true ) ; } ) ; test ( 'isSubpath, win32, true' , ( ) => { let fsPath1 = 'C:\\test' ; let fsPath2 = 'C:\\test\\sub' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . win32 . relative ) , true ) ; fsPath1 = 'C:\\test' ; fsPath2 = 'C:\\test\\sub\\sub2' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . win32 . relative ) , true ) ; } ) ; test ( 'isSubpath, posix, false' , ( ) => { let fsPath1 = '/test/sub' ; let fsPath2 = '/test/' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . posix . relative ) , false ) ; fsPath1 = '/test/sub' ; fsPath2 = '/test2/sub2' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . posix . relative ) , false ) ; fsPath1 = '/test/' ; fsPath2 = '/test/' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . posix . relative ) , false ) ; } ) ; test ( 'isSubpath, win32, false' , ( ) => { let fsPath1 = 'C:\\test\\sub\\' ; let fsPath2 = 'C:\\test\\' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . win32 . relative ) , false ) ; fsPath1 = 'C:\\test\\sub' ; fsPath2 = 'D:\\test2\\sub2' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . win32 . relative ) , false ) ; fsPath1 = 'C:\\test\\' ; fsPath2 = 'C:\\test\\' ; assert . equal ( isSubpath ( fsPath1 , fsPath2 , path . win32 . relative ) , false ) ; } ) ; } ) ;