mirror of https://github.com/actions/toolkit
update tests
parent
6422c3bb5d
commit
5deef5c6b4
|
@ -138,7 +138,7 @@ describe('basics', () => {
|
||||||
|
|
||||||
it('does basic get request with redirects', async () => {
|
it('does basic get request with redirects', async () => {
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`http://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'http://postman-echo.com/get'
|
'http://postman-echo.com/get'
|
||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
|
@ -150,7 +150,7 @@ describe('basics', () => {
|
||||||
|
|
||||||
it('does basic get request with redirects (303)', async () => {
|
it('does basic get request with redirects (303)', async () => {
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`http://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'http://postman-echo.com/get'
|
'http://postman-echo.com/get'
|
||||||
)}&status_code=303`
|
)}&status_code=303`
|
||||||
)
|
)
|
||||||
|
@ -162,8 +162,8 @@ describe('basics', () => {
|
||||||
|
|
||||||
it('returns 404 for not found get request on redirect', async () => {
|
it('returns 404 for not found get request on redirect', async () => {
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`http://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'https://postman-echo.com/status/404'
|
'http://postman-echo.com/status/404'
|
||||||
)}&status_code=303`
|
)}&status_code=303`
|
||||||
)
|
)
|
||||||
expect(res.message.statusCode).toBe(404)
|
expect(res.message.statusCode).toBe(404)
|
||||||
|
@ -177,7 +177,7 @@ describe('basics', () => {
|
||||||
{allowRedirects: false}
|
{allowRedirects: false}
|
||||||
)
|
)
|
||||||
const res: httpm.HttpClientResponse = await http.get(
|
const res: httpm.HttpClientResponse = await http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`http://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'http://postman-echo.com/get'
|
'http://postman-echo.com/get'
|
||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
|
@ -191,7 +191,7 @@ describe('basics', () => {
|
||||||
authorization: 'shhh'
|
authorization: 'shhh'
|
||||||
}
|
}
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`http://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'https://www.postman-echo.com/get'
|
'https://www.postman-echo.com/get'
|
||||||
)}`,
|
)}`,
|
||||||
headers
|
headers
|
||||||
|
@ -213,7 +213,7 @@ describe('basics', () => {
|
||||||
Authorization: 'shhh'
|
Authorization: 'shhh'
|
||||||
}
|
}
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`http://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'https://www.postman-echo.com/get'
|
'https://www.postman-echo.com/get'
|
||||||
)}`,
|
)}`,
|
||||||
headers
|
headers
|
||||||
|
@ -304,7 +304,7 @@ describe('basics', () => {
|
||||||
|
|
||||||
it('getting a non existent json object returns null', async () => {
|
it('getting a non existent json object returns null', async () => {
|
||||||
const jsonObj = await _http.getJson<HttpBinData>(
|
const jsonObj = await _http.getJson<HttpBinData>(
|
||||||
'https://postman-echo.com/status/404'
|
'http://postman-echo.com/status/404'
|
||||||
)
|
)
|
||||||
expect(jsonObj.statusCode).toBe(404)
|
expect(jsonObj.statusCode).toBe(404)
|
||||||
expect(jsonObj.result).toBeNull()
|
expect(jsonObj.result).toBeNull()
|
||||||
|
@ -313,12 +313,12 @@ describe('basics', () => {
|
||||||
it('posts a json object', async () => {
|
it('posts a json object', async () => {
|
||||||
const res = {name: 'foo'}
|
const res = {name: 'foo'}
|
||||||
const restRes = await _http.postJson<HttpBinData>(
|
const restRes = await _http.postJson<HttpBinData>(
|
||||||
'https://postman-echo.com/post',
|
'http://postman-echo.com/post',
|
||||||
res
|
res
|
||||||
)
|
)
|
||||||
expect(restRes.statusCode).toBe(200)
|
expect(restRes.statusCode).toBe(200)
|
||||||
expect(restRes.result).toBeDefined()
|
expect(restRes.result).toBeDefined()
|
||||||
expect(restRes.result?.url).toBe('https://postman-echo.com/post')
|
expect(restRes.result?.url).toBe('http://postman-echo.com/post')
|
||||||
expect(restRes.result?.json.name).toBe('foo')
|
expect(restRes.result?.json.name).toBe('foo')
|
||||||
expect(restRes.result?.headers[httpm.Headers.Accept]).toBe(
|
expect(restRes.result?.headers[httpm.Headers.Accept]).toBe(
|
||||||
httpm.MediaTypes.ApplicationJson
|
httpm.MediaTypes.ApplicationJson
|
||||||
|
@ -334,12 +334,12 @@ describe('basics', () => {
|
||||||
it('puts a json object', async () => {
|
it('puts a json object', async () => {
|
||||||
const res = {name: 'foo'}
|
const res = {name: 'foo'}
|
||||||
const restRes = await _http.putJson<HttpBinData>(
|
const restRes = await _http.putJson<HttpBinData>(
|
||||||
'https://postman-echo.com/put',
|
'http://postman-echo.com/put',
|
||||||
res
|
res
|
||||||
)
|
)
|
||||||
expect(restRes.statusCode).toBe(200)
|
expect(restRes.statusCode).toBe(200)
|
||||||
expect(restRes.result).toBeDefined()
|
expect(restRes.result).toBeDefined()
|
||||||
expect(restRes.result?.url).toBe('https://postman-echo.com/put')
|
expect(restRes.result?.url).toBe('http://postman-echo.com/put')
|
||||||
expect(restRes.result?.json.name).toBe('foo')
|
expect(restRes.result?.json.name).toBe('foo')
|
||||||
|
|
||||||
expect(restRes.result?.headers[httpm.Headers.Accept]).toBe(
|
expect(restRes.result?.headers[httpm.Headers.Accept]).toBe(
|
||||||
|
@ -356,12 +356,12 @@ describe('basics', () => {
|
||||||
it('patch a json object', async () => {
|
it('patch a json object', async () => {
|
||||||
const res = {name: 'foo'}
|
const res = {name: 'foo'}
|
||||||
const restRes = await _http.patchJson<HttpBinData>(
|
const restRes = await _http.patchJson<HttpBinData>(
|
||||||
'https://postman-echo.com/patch',
|
'http://postman-echo.com/patch',
|
||||||
res
|
res
|
||||||
)
|
)
|
||||||
expect(restRes.statusCode).toBe(200)
|
expect(restRes.statusCode).toBe(200)
|
||||||
expect(restRes.result).toBeDefined()
|
expect(restRes.result).toBeDefined()
|
||||||
expect(restRes.result?.url).toBe('https://postman-echo.com/patch')
|
expect(restRes.result?.url).toBe('http://postman-echo.com/patch')
|
||||||
expect(restRes.result?.json.name).toBe('foo')
|
expect(restRes.result?.json.name).toBe('foo')
|
||||||
expect(restRes.result?.headers[httpm.Headers.Accept]).toBe(
|
expect(restRes.result?.headers[httpm.Headers.Accept]).toBe(
|
||||||
httpm.MediaTypes.ApplicationJson
|
httpm.MediaTypes.ApplicationJson
|
||||||
|
|
|
@ -36,7 +36,7 @@ describe('headers', () => {
|
||||||
it('preserves existing headers on postJson', async () => {
|
it('preserves existing headers on postJson', async () => {
|
||||||
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
||||||
let jsonObj = await _http.postJson<any>(
|
let jsonObj = await _http.postJson<any>(
|
||||||
'https://postman-echo.com/post',
|
'http://postman-echo.com/post',
|
||||||
{},
|
{},
|
||||||
additionalHeaders
|
additionalHeaders
|
||||||
)
|
)
|
||||||
|
@ -52,7 +52,7 @@ describe('headers', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonObj = await httpWithHeaders.postJson<any>(
|
jsonObj = await httpWithHeaders.postJson<any>(
|
||||||
'https://postman-echo.com/post',
|
'http://postman-echo.com/post',
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
||||||
|
@ -64,7 +64,7 @@ describe('headers', () => {
|
||||||
it('preserves existing headers on putJson', async () => {
|
it('preserves existing headers on putJson', async () => {
|
||||||
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
||||||
let jsonObj = await _http.putJson<any>(
|
let jsonObj = await _http.putJson<any>(
|
||||||
'https://postman-echo.com/put',
|
'http://postman-echo.com/put',
|
||||||
{},
|
{},
|
||||||
additionalHeaders
|
additionalHeaders
|
||||||
)
|
)
|
||||||
|
@ -80,7 +80,7 @@ describe('headers', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonObj = await httpWithHeaders.putJson<any>(
|
jsonObj = await httpWithHeaders.putJson<any>(
|
||||||
'https://postman-echo.com/put',
|
'http://postman-echo.com/put',
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
||||||
|
@ -92,7 +92,7 @@ describe('headers', () => {
|
||||||
it('preserves existing headers on patchJson', async () => {
|
it('preserves existing headers on patchJson', async () => {
|
||||||
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
||||||
let jsonObj = await _http.patchJson<any>(
|
let jsonObj = await _http.patchJson<any>(
|
||||||
'https://postman-echo.com/patch',
|
'http://postman-echo.com/patch',
|
||||||
{},
|
{},
|
||||||
additionalHeaders
|
additionalHeaders
|
||||||
)
|
)
|
||||||
|
@ -108,7 +108,7 @@ describe('headers', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonObj = await httpWithHeaders.patchJson<any>(
|
jsonObj = await httpWithHeaders.patchJson<any>(
|
||||||
'https://postman-echo.com/patch',
|
'http://postman-echo.com/patch',
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
||||||
|
|
Loading…
Reference in New Issue