1- import { vi } from 'vitest' ;
2- import { Pept2prot } from "../../../lib/commands/unipept/pept2prot" ;
3- import { setupMockFetch } from '../../mocks/mockFetch' ;
1+ import { vi , afterAll } from 'vitest' ;
2+ import { Pept2prot } from "../../../lib/commands/unipept/pept2prot.js" ;
3+ import { setupPolly } from '../../mocks/polly.js' ;
4+ import { Polly } from '@pollyjs/core' ;
45
56let output : string [ ] ;
7+ let polly : Polly ;
8+
69vi
710 . spyOn ( process . stdout , "write" )
811 . mockImplementation ( ( data : unknown ) => { output . push ( data as string ) ; return true ; } ) ;
912
1013beforeAll ( ( ) => {
11- setupMockFetch ( ) ;
14+ polly = setupPolly ( 'pept2prot' ) ;
15+ } ) ;
16+
17+ afterAll ( async ( ) => {
18+ await polly . stop ( ) ;
1219} ) ;
1320
1421beforeEach ( ( ) => {
@@ -20,13 +27,16 @@ test('test with default args', async () => {
2027 await command . run ( [ "AALTER" ] , { header : true , format : "csv" } ) ;
2128 expect ( output [ 0 ] . startsWith ( "peptide,uniprot_id,protein_name,taxon_id,protein" ) ) . toBeTruthy ( ) ;
2229 expect ( output [ 1 ] . startsWith ( "AALTER," ) ) . toBeTruthy ( ) ;
23- expect ( output . length ) . toBe ( 2 ) ;
30+ // Ensure we got some protein data (not just empty commas)
31+ expect ( output [ 1 ] . length ) . toBeGreaterThan ( 10 ) ;
32+ expect ( output . length ) . toBeGreaterThanOrEqual ( 2 ) ;
2433} ) ;
2534
2635test ( 'test with fasta' , async ( ) => {
2736 const command = new Pept2prot ( ) ;
2837 await command . run ( [ ">test" , "AALTER" ] , { header : true , format : "csv" } ) ;
2938 expect ( output [ 0 ] . startsWith ( "fasta_header,peptide,uniprot_id,protein_name,taxon_id,protein" ) ) . toBeTruthy ( ) ;
3039 expect ( output [ 1 ] . startsWith ( ">test,AALTER," ) ) . toBeTruthy ( ) ;
31- expect ( output . length ) . toBe ( 2 ) ;
40+ expect ( output [ 1 ] . length ) . toBeGreaterThan ( 10 ) ;
41+ expect ( output . length ) . toBeGreaterThanOrEqual ( 2 ) ;
3242} ) ;
0 commit comments