chore: run prettier

This commit is contained in:
Roman Hotsiy 2018-07-23 11:17:31 +03:00
parent b41b181dd0
commit 2ff726649c
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 18 additions and 11 deletions

View File

@ -33,7 +33,10 @@ export class RequestSamples extends React.Component<RequestSamplesProps> {
</TabList> </TabList>
{hasBodySample && ( {hasBodySample && (
<TabPanel key="payload"> <TabPanel key="payload">
<div> <PayloadSamples content={requestBodyContent!} /> </div> <div>
{' '}
<PayloadSamples content={requestBodyContent!} />{' '}
</div>
</TabPanel> </TabPanel>
)} )}
{samples.map(sample => ( {samples.map(sample => (

View File

@ -41,14 +41,14 @@ describe('Utils', () => {
}); });
test('slugifyIfAvailable returns original value when cannot slugify the value', () => { test('slugifyIfAvailable returns original value when cannot slugify the value', () => {
const willBeSlugifed = safeSlugify('some string') const willBeSlugifed = safeSlugify('some string');
expect(willBeSlugifed).toEqual('some-string'); expect(willBeSlugifed).toEqual('some-string');
const cannotBeSlugified = '가나다라 마바사' const cannotBeSlugified = '가나다라 마바사';
// if slugify() fixes this issue, safeSlugify should be removed and replaced with original one. // if slugify() fixes this issue, safeSlugify should be removed and replaced with original one.
expect(slugify(cannotBeSlugified)).toEqual(''); expect(slugify(cannotBeSlugified)).toEqual('');
expect(safeSlugify(cannotBeSlugified)).toEqual('가나다라-마바사'); expect(safeSlugify(cannotBeSlugified)).toEqual('가나다라-마바사');
}) });
describe('mergeObjects', () => { describe('mergeObjects', () => {
test('should merge Objects and all nested Ones', () => { test('should merge Objects and all nested Ones', () => {

View File

@ -121,11 +121,15 @@ const isMergebleObject = (item): boolean => {
* the regex codes are referenced with https://gist.github.com/mathewbyrne/1280286 * the regex codes are referenced with https://gist.github.com/mathewbyrne/1280286
*/ */
export function safeSlugify(value: string): string { export function safeSlugify(value: string): string {
return slugify(value) || return (
value.toString().toLowerCase() slugify(value) ||
.replace(/\s+/g, '-') // Replace spaces with - value
.replace(/&/g, '-and-') // Replace & with 'and' .toString()
.replace(/\--+/g, '-') // Replace multiple - with single - .toLowerCase()
.replace(/^-+/, '') // Trim - from start of text .replace(/\s+/g, '-') // Replace spaces with -
.replace(/-+$/, ''); // Trim - from end of text .replace(/&/g, '-and-') // Replace & with 'and'
.replace(/\--+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, '')
); // Trim - from end of text
} }