55 assertStringIncludes ,
66} from "../../testing/asserts.ts" ;
77import { exists , existsSync } from "./_fs_exists.ts" ;
8+ import { promisify } from "../util.ts" ;
89
9- Deno . test ( "existsFile " , async function ( ) {
10+ Deno . test ( "[std/node/fs] exists " , async function ( ) {
1011 const availableFile = await new Promise ( ( resolve ) => {
1112 const tmpFilePath = Deno . makeTempFileSync ( ) ;
1213 exists ( tmpFilePath , ( exists : boolean ) => {
@@ -21,13 +22,24 @@ Deno.test("existsFile", async function () {
2122 assertEquals ( notAvailableFile , false ) ;
2223} ) ;
2324
24- Deno . test ( "existsSyncFile " , function ( ) {
25+ Deno . test ( "[std/node/fs] existsSync " , function ( ) {
2526 const tmpFilePath = Deno . makeTempFileSync ( ) ;
2627 assertEquals ( existsSync ( tmpFilePath ) , true ) ;
2728 Deno . removeSync ( tmpFilePath ) ;
2829 assertEquals ( existsSync ( "./notAvailable.txt" ) , false ) ;
2930} ) ;
3031
32+ Deno . test ( "[std/node/fs] promisify(exists)" , async ( ) => {
33+ const tmpFilePath = await Deno . makeTempFile ( ) ;
34+ try {
35+ const existsPromisified = promisify ( exists ) ;
36+ assert ( await existsPromisified ( tmpFilePath ) ) ;
37+ assert ( ! await existsPromisified ( "./notAvailable.txt" ) ) ;
38+ } finally {
39+ await Deno . remove ( tmpFilePath ) ;
40+ }
41+ } ) ;
42+
3143Deno . test ( "[std/node/fs] exists callback isn't called twice if error is thrown" , async ( ) => {
3244 // This doesn't use `assertCallbackErrorUncaught()` because `exists()` doesn't return a standard node callback, which is what it expects.
3345 const tempFile = await Deno . makeTempFile ( ) ;
0 commit comments