-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e56f901
commit e908f2c
Showing
8 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
jest.config.js | ||
jest.config.js | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
npm run lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
npm run build | ||
npm test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { validateConfig } from "./validate-config"; | ||
import { Config } from "../../types/config"; | ||
|
||
describe("validateConfig", () => { | ||
it("should not throw an error if config is valid", () => { | ||
const validConfig: Config = { | ||
endpoints: [ | ||
{ | ||
name: "endpoint1", | ||
method: "GET", | ||
path: "/path1", | ||
destination: { | ||
url: "http:https://example.com", | ||
}, | ||
}, | ||
{ | ||
name: "endpoint2", | ||
method: "POST", | ||
path: "/path2", | ||
destination: { | ||
url: "http:https://example.com", | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
expect(() => validateConfig(validConfig)).not.toThrow(); | ||
}); | ||
|
||
it("should throw an error if endpoint names are duplicated", () => { | ||
const invalidConfig: Config = { | ||
endpoints: [ | ||
{ | ||
name: "duplicate", | ||
method: "GET", | ||
path: "/path1", | ||
destination: { | ||
url: "http:https://example.com", | ||
}, | ||
}, | ||
{ | ||
name: "duplicate", | ||
method: "GET", | ||
path: "/path2", | ||
destination: { | ||
url: "http:https://example.com", | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
expect(() => validateConfig(invalidConfig)).toThrow(); | ||
}); | ||
|
||
it("should throw an error if endpoint path/method combination is duplicated", () => { | ||
const invalidConfig: Config = { | ||
endpoints: [ | ||
{ | ||
name: "endpoint1", | ||
method: "GET", | ||
path: "/duplicate", | ||
destination: { | ||
url: "http:https://example.com", | ||
}, | ||
}, | ||
{ | ||
name: "endpoint2", | ||
method: "GET", | ||
path: "/duplicate", | ||
destination: { | ||
url: "http:https://example.com", | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
expect(() => validateConfig(invalidConfig)).toThrow(); | ||
}); | ||
|
||
it("should throw an error if destination URL is invalid", () => { | ||
const invalidUrlConfig: Config = { | ||
endpoints: [ | ||
{ | ||
name: "endpoint", | ||
method: "GET", | ||
path: "/path", | ||
destination: { | ||
url: "invalid_url", | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
expect(() => validateConfig(invalidUrlConfig)).toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "commonjs", | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"outDir": "./dist" | ||
} | ||
} |