PromucFlow_constructor/app/client/packages/utils/src/validateApiPath/validateApiPath.test.ts
Valera Melnikov d5bd30202e
fix: move ee utitls (#38986)
## Description
Move mised utilities from the EE repo. [Part of EE
PR](https://github.com/appsmithorg/appsmith-ee/pull/6082).


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced utilities to simplify file handling by extracting
extensions and base names.
- Added a function to construct URL-friendly text fragments from string
arrays.
- Implemented a utility to validate that API paths use a secure
protocol.

- **Tests**
- Added unit tests to ensure proper behavior for URL fragment
construction and API path validation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-02-04 09:43:13 +03:00

18 lines
519 B
TypeScript

import { validateApiPath } from "./validateApiPath";
describe("validateApiPath", () => {
it("should return the path if it starts with 'https://'", () => {
const validPath = "https://example.com";
expect(validateApiPath(validPath)).toBe(validPath);
});
it("should throw an error if the path does not start with 'https://'", () => {
const invalidPath = "example.com";
expect(() => validateApiPath(invalidPath)).toThrow(
"The example.com path must start with 'https://'.",
);
});
});