Skip to content

Commit

Permalink
Add tests for cp and mv (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 authored Nov 1, 2024
1 parent 01b480f commit ff15105
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/tests/command/cp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect } from '@playwright/test';
import { shellLineSimpleN, test } from '../utils';

test.describe('cp command', () => {
test('should copy single file', async ({ page }) => {
const output = await shellLineSimpleN(page, [
// Check initial conditions
'ls file1',
'ls copy',
'cat file1',
// Copy file
'cp file1 copy',
// Check results
'ls file1',
'ls copy',
'cat file1',
'cat copy'
]);
expect(output[0]).toMatch(/^ls file1\r\nfile1\r\n/);
expect(output[1]).toMatch(/cannot access 'copy': No such file or directory/);
expect(output[2]).toMatch(/^cat file1\r\nContents of the file\r\n/);
expect(output[4]).toMatch(/^ls file1\r\nfile1\r\n/);
expect(output[5]).toMatch(/^ls copy\r\ncopy\r\n/);
expect(output[6]).toMatch(/^cat file1\r\nContents of the file\r\n/);
expect(output[7]).toMatch(/^cat copy\r\nContents of the file\r\n/);
});
});
25 changes: 25 additions & 0 deletions test/tests/command/mv.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect } from '@playwright/test';
import { shellLineSimpleN, test } from '../utils';

test.describe('mv command', () => {
test('should move single file', async ({ page }) => {
const output = await shellLineSimpleN(page, [
// Check initial conditions
'ls file1',
'ls copy',
'cat file1',
// Move file
'mv file1 copy',
// Check results
'ls file1',
'ls copy',
'cat copy'
]);
expect(output[0]).toMatch(/^ls file1\r\nfile1\r\n/);
expect(output[1]).toMatch(/cannot access 'copy': No such file or directory/);
expect(output[2]).toMatch(/^cat file1\r\nContents of the file\r\n/);
expect(output[4]).toMatch(/cannot access 'file1': No such file or directory/);
expect(output[5]).toMatch(/^ls copy\r\ncopy\r\n/);
expect(output[6]).toMatch(/^cat copy\r\nContents of the file\r\n/);
});
});

0 comments on commit ff15105

Please sign in to comment.