feat: Create category component (#5103)

This commit is contained in:
Muhsin Keloth
2022-07-26 12:15:01 +05:30
committed by GitHub
parent 92bb84127b
commit bd7a56061e
7 changed files with 264 additions and 9 deletions

View File

@@ -62,9 +62,16 @@ export const createPendingMessage = data => {
return pendingMessage;
};
export const convertToSlug = text => {
export const convertToAttributeSlug = text => {
return text
.toLowerCase()
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '_');
};
export const convertToCategorySlug = text => {
return text
.toLowerCase()
.replace(/[^\w ]+/g, '')
.replace(/ +/g, '-');
};

View File

@@ -1,7 +1,8 @@
import {
getTypingUsersText,
createPendingMessage,
convertToSlug,
convertToAttributeSlug,
convertToCategorySlug,
} from '../commons';
describe('#getTypingUsersText', () => {
@@ -88,8 +89,18 @@ describe('#createPendingMessage', () => {
});
});
describe('convertToSlug', () => {
describe('convertToAttributeSlug', () => {
it('should convert to slug', () => {
expect(convertToSlug('Test@%^&*(){}>.!@`~_ ing')).toBe('test__ing');
expect(convertToAttributeSlug('Test@%^&*(){}>.!@`~_ ing')).toBe(
'test__ing'
);
});
});
describe('convertToCategorySlug', () => {
it('should convert to slug', () => {
expect(convertToCategorySlug('User profile guide')).toBe(
'user-profile-guide'
);
});
});