-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove alpha for content source maps
- Loading branch information
1 parent
15b7d71
commit ee2909c
Showing
10 changed files
with
50 additions
and
72 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
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
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
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,44 +1,33 @@ | ||
import { | ||
checkIncludeContentSourceMapsParamIsAllowed, | ||
checkIncludeContentSourceMapsParamIsValid, | ||
} from '../../../lib/utils/validate-params' | ||
import { checkIncludeContentSourceMapsParamIsAllowed } from '../../../lib/utils/validate-params' | ||
import { ValidationError } from '../../../lib/utils/validation-error' | ||
|
||
describe('checkIncludeContentSourceMapsParamIsValid', () => { | ||
it('returns false if host/alphaFeatures is not provided', () => { | ||
expect(checkIncludeContentSourceMapsParamIsValid()).toBe(false) | ||
describe('checkIncludeContentSourceMapsParamIsAllowed', () => { | ||
it('returns false if includeContentSourceMaps is not provided', () => { | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('http://example.com')).toBe(false) | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('http://example.com', undefined)).toBe(false) | ||
}) | ||
|
||
it('throws ValidationError if includeContentSourceMaps is not a boolean', () => { | ||
expect(() => | ||
checkIncludeContentSourceMapsParamIsValid({ includeContentSourceMaps: 'not a boolean' }), | ||
checkIncludeContentSourceMapsParamIsAllowed('http://example.com', 'not a boolean' as any), | ||
).toThrow(ValidationError) | ||
expect(() => | ||
checkIncludeContentSourceMapsParamIsAllowed('http://example.com', 1 as any), | ||
).toThrow(ValidationError) | ||
}) | ||
|
||
it('returns true if includeContentSourceMaps is a boolean', () => { | ||
expect(checkIncludeContentSourceMapsParamIsValid({ includeContentSourceMaps: true })).toBe(true) | ||
it('throws ValidationError if includeContentSourceMaps is true but host is not preview.contentful.com', () => { | ||
expect(() => checkIncludeContentSourceMapsParamIsAllowed('cdn.contentful.com', true)).toThrow( | ||
ValidationError, | ||
) | ||
}) | ||
}) | ||
|
||
describe('checkIncludeContentSourceMapsParamIsAllowed', () => { | ||
it('returns false if alphaFeatures is not provided', () => { | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('http://example.com')).toBe(false) | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('http://example.com', {})).toBe(false) | ||
}) | ||
|
||
it('throws ValidationError if includeContentSourceMaps is valid but baseUrl does not include preview.contentful.com', () => { | ||
expect(() => | ||
checkIncludeContentSourceMapsParamIsAllowed('cdn.contentful.com', { | ||
includeContentSourceMaps: true, | ||
}), | ||
).toThrow(ValidationError) | ||
it('returns true if includeContentSourceMaps is true and host is preview.contentful.com', () => { | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('preview.contentful.com', true)).toBe(true) | ||
}) | ||
|
||
it('returns true if includeContentSourceMaps is valid and baseUrl includes preview.contentful.com', () => { | ||
expect( | ||
checkIncludeContentSourceMapsParamIsAllowed('preview.contentful.com', { | ||
includeContentSourceMaps: true, | ||
}), | ||
).toBe(true) | ||
it('returns false if includeContentSourceMaps is false, regardless of host', () => { | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('preview.contentful.com', false)).toBe(false) | ||
expect(checkIncludeContentSourceMapsParamIsAllowed('cdn.contentful.com', false)).toBe(false) | ||
}) | ||
}) |