Skip to content

Commit

Permalink
test: write tests for regex match
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhood Shapouran committed Mar 28, 2023
1 parent 9858bb7 commit fb5f496
Showing 1 changed file with 20 additions and 38 deletions.
58 changes: 20 additions & 38 deletions src/__tests__/regex.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,36 @@ import {
} from '../regexes';

it('Check the input is a Mention', () => {
expect(mentionRegexTester.test('@farhoodme')).toBeTruthy();
expect('@farhoodme').toMatch(mentionRegexTester);
});

it('Check the input is a Hashtag', () => {
expect(hashtagRegexTester.test('#test')).toBeTruthy();
});

it('Check the input is a Hashtag', () => {
expect(hashtagRegexTester.test('#şikayet')).toBeTruthy();
});

it('Check the input is a Hashtag', () => {
expect(hashtagRegexTester.test('تست#')).toBeTruthy();
});

it('Check the input is a Hashtag', () => {
expect(hashtagRegexTester.test('#测试')).toBeTruthy();
});

it('Check the input is a Hashtag', () => {
expect(hashtagRegexTester.test('#тест')).toBeTruthy();
});

it('Check the input is a Hashtag', () => {
expect(hashtagRegexTester.test('#prüfen')).toBeTruthy();
expect('#test').toMatch(hashtagRegexTester);
expect('#şikayet').toMatch(hashtagRegexTester);
expect('تست#').toMatch(hashtagRegexTester);
expect('#测试').toMatch(hashtagRegexTester);
expect('#тест').toMatch(hashtagRegexTester);
expect('#prüfen').toMatch(hashtagRegexTester);
});

it('Check the input not a Hashtag', () => {
expect(hashtagRegexTester.test('test#test')).toBeFalsy();
expect('test#test').not.toMatch(hashtagRegexTester);
});

it('Check the input is an Email Address', () => {
expect(emailRegexTester.test('[email protected]')).toBeTruthy();
expect('[email protected]').toMatch(emailRegexTester);
expect('[email protected]').toMatch(emailRegexTester);
});

it('Check the input is an Url', () => {
expect(
urlRegexTester.test(
'https://www.asd.google.com/search?q=some+text&param=3#dfsdf'
)
).toBeTruthy();
expect(urlRegexTester.test('http://www.google.com')).toBeTruthy();
expect(urlRegexTester.test('www.google.com')).toBeTruthy();
expect(
urlRegexTester.test('https://google.com/?q=some+text&param=3#dfsdf')
).toBeTruthy();
expect(urlRegexTester.test('https://www.google.com/api/')).toBeTruthy();
expect(
urlRegexTester.test('https://www.google.com/api/login.php')
).toBeTruthy();
expect('https://www.asd.google.com/search?q=some+text&param=3#dfsdf').toMatch(
urlRegexTester
);
expect('http://www.google.com').toMatch(urlRegexTester);
expect('www.google.com').toMatch(urlRegexTester);
expect('https://google.com/?q=some+text&param=3#dfsdf').toMatch(
urlRegexTester
);
expect('https://www.google.com/api/').toMatch(urlRegexTester);
expect('https://www.google.com/api/login.php').toMatch(urlRegexTester);
});

0 comments on commit fb5f496

Please sign in to comment.