| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f8d3ea9 commit c5f22cb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,6 +33,11 @@ const dirclosedError = { | |||
| 33 | 33 | code: 'ERR_DIR_CLOSED' | |
| 34 | 34 | }; | |
| 35 | 35 | ||
| 36 | + const invalidCallbackObj = { | ||
| 37 | + code: 'ERR_INVALID_CALLBACK', | ||
| 38 | + name: 'TypeError' | ||
| 39 | + }; | ||
| 40 | + | ||
| 36 | 41 | // Check the opendir Sync version | |
| 37 | 42 | { | |
| 38 | 43 | const dir = fs.opendirSync(testDir); | |
@@ -209,3 +214,19 @@ for (const bufferSize of ['', '1', null]) { | |||
| 209 | 214 | assertDirent(dir.readSync()); | |
| 210 | 215 | dir.close(); | |
| 211 | 216 | } | |
| 217 | + | ||
| 218 | + // Check that when passing a string instead of function - throw an exception | ||
| 219 | + async function doAsyncIterInvalidCallbackTest() { | ||
| 220 | + const dir = await fs.promises.opendir(testDir); | ||
| 221 | + assert.throws(() => dir.close('not function'), invalidCallbackObj); | ||
| 222 | + } | ||
| 223 | + doAsyncIterInvalidCallbackTest().then(common.mustCall()); | ||
| 224 | + | ||
| 225 | + // Check if directory already closed - throw an exception | ||
| 226 | + async function doAsyncIterDirClosedTest() { | ||
| 227 | + const dir = await fs.promises.opendir(testDir); | ||
| 228 | + await dir.close(); | ||
| 229 | + | ||
| 230 | + assert.throws(() => dir.close(), dirclosedError); | ||
| 231 | + } | ||
| 232 | + doAsyncIterDirClosedTest().then(common.mustCall()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments