Skip to content

Commit

Permalink
tests - fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brianvoe committed Dec 27, 2024
1 parent d41d69c commit a30fb27
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
14 changes: 10 additions & 4 deletions src/gimmeHTTP/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Register, Generate, Settings, Config, Http, Builder } from './index'
import { beforeAll, describe, expect, test } from '@jest/globals'
import { Register, Generate, Settings, Config, Http, Builder, ClearRegistry } from './index'
import { beforeEach, describe, expect, test } from '@jest/globals'
import ShellCurl from './targets/shell.curl'

describe('Index', () => {
beforeAll(() => {
beforeEach(() => {
ClearRegistry()
Register(ShellCurl)
})

Expand Down Expand Up @@ -123,6 +124,11 @@ curl -X POST "https://example.com" \\
expect(error).toBeUndefined()
}

expect(code).toEqual('url: https://example.com\nmethod: GET')
expect(code).toEqual(
`
url: https://example.com
method: GET
`.trim()
)
})
})
6 changes: 3 additions & 3 deletions src/gimmeHTTP/targets/node.http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const http = require("http");
const options = {
method: "POST",
hostname: "example.com",
path: "/api",
path: "/",
headers: {
"Content-Type": "application/json",
},
Expand Down Expand Up @@ -64,7 +64,7 @@ const http = require("http");
const options = {
method: "GET",
hostname: "example.com",
path: "/api",
path: "/",
};
const req = http.request(options, (res) => {
Expand Down Expand Up @@ -102,7 +102,7 @@ const http = require("http");
const options = {
method: "POST",
hostname: "example.com",
path: "/api",
path: "/",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer token",
Expand Down
8 changes: 4 additions & 4 deletions src/gimmeHTTP/targets/python.http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import json
conn = http.client.HTTPSConnection("example.com", 443)
conn.request("GET", "/api")
conn.request("GET", "/")
res = conn.getresponse()
data = res.read()
Expand Down Expand Up @@ -49,7 +49,7 @@ headers = {
"Authorization": "Bearer token",
}
conn.request("POST", "/api", headers)
conn.request("POST", "/", headers)
res = conn.getresponse()
data = res.read()
Expand Down Expand Up @@ -77,7 +77,7 @@ conn = http.client.HTTPSConnection("example.com", 443)
payload = json.dumps({"key1":"value1"})
conn.request("POST", "/api", payload)
conn.request("POST", "/", payload)
res = conn.getresponse()
data = res.read()
Expand Down Expand Up @@ -116,7 +116,7 @@ cookies = {
"session": "1234",
}
conn.request("POST", "/api", headers, cookies)
conn.request("POST", "/", headers, cookies)
res = conn.getresponse()
data = res.read()
Expand Down

0 comments on commit a30fb27

Please sign in to comment.