-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: throw a proper error message on invalid environment or API type
- Loading branch information
Showing
2 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/api-headless-cms/__tests__/environmentUrl.test.js
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,22 @@ | ||
import useContentHandler from "./utils/useContentHandler"; | ||
|
||
describe("Invalid type and environment URL params test", () => { | ||
it("should respond with proper error messages", async () => { | ||
const { invoke } = useContentHandler(); | ||
let [body1] = await invoke({ | ||
pathParameters: { key: "read123/xyz" } | ||
}); | ||
|
||
expect(body1.error.message).toEqual( | ||
"Could not load environment, please check if the passed environment alias slug or environment ID is correct." | ||
); | ||
|
||
let [body2] = await invoke({ | ||
pathParameters: { key: "read/xyz" } | ||
}); | ||
|
||
expect(body2.error.message).toEqual( | ||
"Could not load environment, please check if the passed environment alias slug or environment ID is correct." | ||
); | ||
}); | ||
}); |
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