import nock from 'nock' ; import assert from 'power-assert' ; import { Webhooks } from '../../../../app/plugin/gitee/gitee-raw-client/webhooks' ; describe ( 'gitee raw client repos' , ( ) => { let webhooks ; before ( async ( ) => { webhooks = new Webhooks ( '' ) ; } ) ; it ( 'get all webhooks' , async ( ) => { nock ( 'https://gitee.com' ) . get ( '/api/v5/repos/goodmeowing/push_test/hooks' ) . reply ( 200 , '{"hi": 123}' ) ; const result = await webhooks . all ( { owner : 'goodmeowing' , repo : 'push_test' , } ) ; assert . deepStrictEqual ( result , { hi : 123 } ) ; } ) ; it ( 'create webhook' , async ( ) => { nock ( 'https://gitee.com' ) . post ( '/api/v5/repos/goodmeowing/push_test/hooks' ) . reply ( 200 , '{"hi": 123}' ) ; const result = await webhooks . addWebhook ( { owner : 'goodmeowing' , repo : 'push_test' , url : 'https://smee.io/7ynZ7HZRRiAcuAx' , } ) ; assert . deepStrictEqual ( result , { hi : 123 } ) ; } ) ; } ) ;