mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
fix: setup Jest with TS
This commit is contained in:
1 parent
557af91d4b
commit
a18e0d9b68
12 files changed
+45
-9
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { buildFileCheckCmd } from '../src/commands'
|
||||
|
||||
describe('buildFileCheckCmd function', () => {
|
||||
it('builds the file check command correctly', () => {
|
||||
const testcases = [
|
||||
{
|
||||
input: { path: '/etc/passwd', type: 'file' },
|
||||
output: ['test', '-f', '/etc/passwd'],
|
||||
},
|
||||
{
|
||||
input: { path: '/etc', type: 'folder' },
|
||||
output: ['test', '-d', '/etc'],
|
||||
},
|
||||
{
|
||||
input: { path: '/tmp/socket', type: 'socket' },
|
||||
output: ['test', '-S', '/tmp/socket'],
|
||||
},
|
||||
{
|
||||
input: { path: '/tmp/link', type: 'link' },
|
||||
output: ['test', '-L', '/tmp/link'],
|
||||
},
|
||||
{
|
||||
input: { path: '/unknown', type: 'unknown' },
|
||||
output: ['test', '-e', '/unknown'],
|
||||
},
|
||||
// Add some injection tests
|
||||
{
|
||||
input: { path: '/etc/passwd;ls', type: 'file' },
|
||||
output: ['test', '-f', '/etc/passwdls'],
|
||||
},
|
||||
{
|
||||
input: { path: '/etc/passwd && ls', type: 'file' },
|
||||
output: ['test', '-f', '/etc/passwdls'],
|
||||
},
|
||||
]
|
||||
|
||||
testcases.forEach(({ input, output }) => {
|
||||
expect(buildFileCheckCmd(input)).toStrictEqual(output)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user