-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { Prot2pept } from '../../lib/commands/prot2pept'; | ||
import { jest } from '@jest/globals'; | ||
import * as mock from 'mock-stdin'; | ||
|
||
let output: string[]; | ||
let error: string[]; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const writeSpy = jest | ||
.spyOn(process.stdout, "write") | ||
.mockImplementation((data: unknown) => { output.push(data as string); return true; }); | ||
const errorSpy = jest | ||
.spyOn(process.stderr, "write") | ||
.mockImplementation((data: unknown) => { error.push(data as string); return true; }); | ||
|
||
beforeEach(() => { | ||
output = []; | ||
error = []; | ||
}); | ||
|
||
test('test single line input 1', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept(); | ||
const run = command.run(); | ||
|
||
stdin.send("AALTERAALTERPAALTER\n"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe("AALTER\nAALTERPAALTER"); | ||
}); | ||
|
||
test('test single line input 2', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept(); | ||
const run = command.run(); | ||
|
||
stdin.send("KRKPR\n"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe("K\nR\nKPR"); | ||
}); | ||
|
||
test('test multi line input', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept(); | ||
const run = command.run(); | ||
|
||
stdin.send("AALTERAALTERPAALTER\n"); | ||
stdin.send("AALTERAA\n"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe("AALTER\nAALTERPAALTER\nAALTER\nAA"); | ||
}); | ||
|
||
test('test fasta input 1', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept(); | ||
const run = command.run(); | ||
|
||
stdin.send(">AKA\nAALTERAALTERPAALTER\n"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe(">AKA\nAALTER\nAALTERPAALTER"); | ||
}); | ||
|
||
test('test fasta input 2', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept(); | ||
const run = command.run(); | ||
|
||
stdin.send(">AKA\nAAL\nT\nERAALTER\nP\nAALTER\n"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe(">AKA\nAALTER\nAALTERPAALTER"); | ||
}); | ||
|
||
test('test fasta input 3', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept(); | ||
const run = command.run(); | ||
|
||
stdin.send(">AKA\nAAL\nT\n>\nERAALTER\nP\nAALTER"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe(">AKA\nAALT\n>\nER\nAALTERPAALTER"); | ||
}); | ||
|
||
test('test custom pattern', async () => { | ||
const stdin = mock.stdin(); | ||
|
||
const command = new Prot2pept({ args: ["--pattern", "([KR])([^A])"] }); | ||
const run = command.run(); | ||
|
||
stdin.send("AALTERAALTERPAALTER\n"); | ||
stdin.end(); | ||
|
||
await run; | ||
|
||
expect(errorSpy).toHaveBeenCalledTimes(0); | ||
expect(output.join("").trimEnd()).toBe("AALTERAALTER\nPAALTER"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
"module": "NodeNext", | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"target": "esnext" | ||
} | ||
} |