Skip to content

Commit

Permalink
Add tests for using keyword support
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Dec 23, 2023
1 parent bf10417 commit 29e44ce
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Path from '../lib/path.js';
import t from 'tap';

t.test('Path', async t => {
t.test('using keyword for temporary files', async t => {
let check = Path.currentFile();

t.test('dispose', t => {
{
using dir = Path.tempDirSync();
check = new Path(dir.toString());
const file = dir.child('foo.txt');
t.equal(file.writeFileSync('works').readFileSync('utf-8'), 'works');
t.same(check.existsSync(), true);
}
t.same(check.existsSync(), false);
t.end();
});

await t.test('asyncDispose', async t => {
let check = Path.currentFile();
{
await using dir = await Path.tempDir();
check = new Path(dir.toString());
const file = dir.child('foo.txt');
t.equal(file.writeFileSync('works too').readFileSync('utf-8'), 'works too');
t.same(await check.exists(), true);
}
t.same(await check.exists(), false);
});
});
});

0 comments on commit 29e44ce

Please sign in to comment.