-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[email protected] into main ☄️
- Loading branch information
Showing
84 changed files
with
4,706 additions
and
1,145 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
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
15 changes: 15 additions & 0 deletions
15
bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.test.ts
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,15 @@ | ||
import { validateBaseUrl } from './validateBaseUrl'; | ||
|
||
describe('validateBaseUrl', () => { | ||
test('Should correctly handle baseUrl only with correct type', () => { | ||
const correctBaseUrls = ['/stringWithLeadingSlash', undefined]; | ||
correctBaseUrls.forEach((correctBaseUrl) => { | ||
expect(() => validateBaseUrl(correctBaseUrl)).not.toThrow(Error); | ||
}); | ||
|
||
const incorrectBaseUrls = ['stringWithoutLeadingSlash', true, 3000, null, {}, [], () => {}]; | ||
incorrectBaseUrls.forEach((incorrectBaseUrl) => { | ||
expect(() => validateBaseUrl(incorrectBaseUrl)).toThrow(new Error('baseUrl')); | ||
}); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
bin/validateMockServerConfig/validateBaseUrl/validateBaseUrl.ts
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,8 @@ | ||
export const validateBaseUrl = (baseUrl: unknown) => { | ||
if (typeof baseUrl !== 'string' && typeof baseUrl !== 'undefined') { | ||
throw new Error('baseUrl'); | ||
} | ||
if (typeof baseUrl === 'string' && !baseUrl.startsWith('/')) { | ||
throw new Error('baseUrl'); | ||
} | ||
}; |
Oops, something went wrong.