Skip to content

Commit

Permalink
Add more test cases for the rmdir step
Browse files Browse the repository at this point in the history
  • Loading branch information
reimic committed Feb 9, 2024
1 parent ce17021 commit a50429a
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions packages/playground/blueprints/src/lib/steps/rmdir.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,40 @@ describe('Blueprint step rmdir()', () => {
});

it('should remove a directory', async () => {
php.mkdir(`/${docroot}/dir1.php`);
php.mkdir(`/${docroot}/dir1`);
await rmdir(php, {
path: `/${docroot}/dir1.php`,
path: `/${docroot}/dir1`,
});
expect(php.fileExists(`/${docroot}/dir1.php`)).toBe(false);
expect(php.fileExists(`/${docroot}/dir1`)).toBe(false);
});

it('should remove a directory with a subdirectory', async () => {
php.mkdir(`/${docroot}/dir1`);
php.mkdir(`/${docroot}/dir1/dir11`);
await rmdir(php, {
path: `/${docroot}/dir1`,
});
expect(php.fileExists(`/${docroot}/dir1/dir11`)).toBe(false);
expect(php.fileExists(`/${docroot}/dir1`)).toBe(false);
});

it('should remove a directory with a file', async () => {
php.mkdir(`/${docroot}/dir1`);
php.writeFile(
`/${docroot}/dir1/index.php`,
`<?php echo 'Hello World';`
);
await rmdir(php, {
path: `/${docroot}/dir1`,
});
expect(php.fileExists(`/${docroot}/dir1/index.php`)).toBe(false);
expect(php.fileExists(`/${docroot}/dir1`)).toBe(false);
});

it('should fail when the directory does not exist', async () => {
await expect(
rmdir(php, {
path: `/${docroot}/dir1.php`,
path: `/${docroot}/dir1`,
})
).rejects.toThrow(/There is no such file or directory/);
});
Expand Down

0 comments on commit a50429a

Please sign in to comment.