11import axios from 'axios'
22
33import { stub , spy } from 'sinon'
4- import { getWebhook , createWebhook } from '../../src/webhooks'
4+ import {
5+ getWebhook ,
6+ createOrUpdateWebhook ,
7+ deleteWebhook
8+ } from '../../src/webhooks'
59
610beforeEach ( ( ) => {
711 stub ( axios , 'request' ) . returns ( { } )
@@ -18,7 +22,7 @@ test('List webhooks has the correct path and method', () => {
1822} )
1923
2024test ( 'Create a new webhooks has the correct path and method' , ( ) => {
21- createWebhook ( axios , {
25+ createOrUpdateWebhook ( axios , {
2226 uid : 2 ,
2327 tag : 'test' ,
2428 url : 'http://test.com' ,
@@ -29,10 +33,20 @@ test('Create a new webhooks has the correct path and method', () => {
2933} )
3034
3135test ( 'Create a new webhooks requires a url' , ( ) => {
32- expect ( ( ) => createWebhook ( axios , { uid : 2 , tag : 'test' } ) ) . toThrow ( )
36+ expect ( ( ) => createOrUpdateWebhook ( axios , { uid : 2 , tag : 'test' } ) ) . toThrow ( )
3337} )
3438
3539test ( 'Create a new webhooks sends the correct payload' , ( ) => {
36- createWebhook ( axios , { uid : 2 , tag : 'test' , url : 'http://example.com' } )
40+ createOrUpdateWebhook ( axios , {
41+ uid : 2 ,
42+ tag : 'test' ,
43+ url : 'http://example.com'
44+ } )
3745 expect ( axios . request . args [ 0 ] [ 0 ] . data . url ) . toBe ( 'http://example.com' )
3846} )
47+
48+ test ( 'Delete a webhook has the correct path and method' , ( ) => {
49+ deleteWebhook ( axios , { uid : 2 , tag : 'test' } )
50+ expect ( axios . request . args [ 0 ] [ 0 ] . method ) . toBe ( 'delete' )
51+ expect ( axios . request . args [ 0 ] [ 0 ] . url ) . toBe ( '/forms/2/webhooks/test' )
52+ } )
0 commit comments