webhook-action/__tests__/main.test.ts

32 lines
970 B
TypeScript
Raw Normal View History

2024-03-28 02:25:32 +00:00
import {http} from '../src/http'
2022-11-10 13:06:47 +00:00
import {expect, test} from '@jest/globals'
test('it makes a post request', async () => {
2024-03-28 02:25:32 +00:00
const url = 'https://httpbin.org/post'
const body = '{"hello": "world"}'
const res = await http.make(url, body)
expect(res.status).toBe(200)
2022-11-10 13:15:52 +00:00
})
test('it makes a post request with insecure', async () => {
2024-03-28 02:25:32 +00:00
const url = 'https://httpbin.org/post'
const body = '{"hello": "world"}'
const insecure = true
const res = await http.make(url, body, null, insecure)
expect(res.status).toBe(200)
2022-11-10 13:15:52 +00:00
})
test('it makes a post request with headers', async () => {
2024-03-28 02:25:32 +00:00
const url = 'https://httpbin.org/post'
const body = '{"hello": "world"}'
const headers = '{"Content-Type": "application/json"}'
const res = await http.make(url, body, headers)
expect(res.status).toBe(200)
2022-11-10 13:15:52 +00:00
})
test('it doesnt require a body', async () => {
2024-03-28 02:25:32 +00:00
const url = 'https://httpbin.org/post'
const res = await http.make(url, null)
expect(res.status).toBe(200)
})