Skip to content

Commit

Permalink
test: FileHandle.appendFile
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Apr 23, 2022
1 parent c1ef64d commit a8feb13
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/yarnpkg-fslib/tests/patchedFs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,24 @@ describe(`patchedFs`, () => {
await expect(patchedFs.promises.readFile(filepath, `utf8`)).resolves.toEqual(`foobar`);
});
});

it(`should support FileHandle.appendFile`, async () => {
const patchedFs = extendFs(fs, new PosixFS(new NodeFS()));

await xfs.mktempPromise(async dir => {
const filepath = npath.join(npath.fromPortablePath(dir), `foo.txt`);
await patchedFs.promises.writeFile(filepath, `foo`);

const fd = await patchedFs.promises.open(filepath, `r+`);

// Move to the end of the file
await fd.readFile();

await expect(fd.appendFile(`bar`)).resolves.toBeUndefined();

await fd.close();

await expect(patchedFs.promises.readFile(filepath, `utf8`)).resolves.toEqual(`foobar`);
});
});
});

0 comments on commit a8feb13

Please sign in to comment.