import { Agent } from 'egg' ; import { initWebhooks } from '../plugin/github/GitHubTestUtil' ; import { prepareTestApplication , testClear } from '../Util' ; import { MockApplication } from 'egg-mock' ; import { genPlantUmlUrl } from '../../scripts/Utils' ; describe ( 'Umlrenderer Controller' , ( ) => { let app ; let agent ; before ( async ( ) => { ( { app , agent } = await prepareTestApplication ( ) as any ) ; await initWebhooks ( app ) ; } ) ; after ( ( ) => { testClear ( app , agent ) ; } ) ; describe ( 'GET /umlrenderer/:installationName/:owner/:repo' , ( ) => { it ( 'should status 302 and redirect' , async ( ) => { const client = await app . github . getClient ( 0 , 'owner/repo' ) ; const fileContent = await ( client as any ) . getFileContent ( 'path' ) ; const plantUmlUrl = genPlantUmlUrl ( fileContent . content ) ; return app . httpRequest ( ) . get ( '/umlrenderer/github/owner/repo?path=path' ) . expect ( 302 ) . expect ( `Redirecting to <a href="${ plantUmlUrl }">${ plantUmlUrl }</a>.` ) ; } ) ; it ( 'should status 200 but cannot get the client' , async ( ) => { return app . httpRequest ( ) . get ( '/umlrenderer/github/owner2/repo2?path=path' ) . expect ( 200 ) . expect ( 'Client not found' ) ; } ) ; } ) ; } ) ;