Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended changes #19

Merged
merged 9 commits into from
Oct 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/utils/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,23 @@ describe('Regex Replace', () => {
expect(regExpMatch('/(\\d+\\.)?\\d+$/', '200,000 400')).toEqual('400')
})
it('should find case senstive words ', () => {
expect(regExpMatch('/([A-Z])\\w+/', 'potato and Superman')).toEqual(
'Superman'
)
expect(regExpMatch('/([A-Z])\\w+/', 'potato and Superman')).toEqual('Superman')
})
it('should throw error if no match found ', () => {
expect(regExpMatch.bind(null, '/\\d/', 'hello world')).toThrow('No match')
})
it('should find a date with the specific format', () => {
expect(regExpMatch('/\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d/', 'My number is 415-555-4242.')).toEqual('415-555-4242')
})
it('should throw "no match" because starting letter is b in regex and f in text', () => {
expect(regExpMatch.bind(null,'/^b\\w+/', 'foobar')).toThrow('No match')
})
it('should find a string with b', () => {
expect(regExpMatch('/b\\w+/', 'foobar')).toEqual('bar')
})
it('should find a word that starts with one or more word characters, has "@" and ends with one or more word characters', () => {
expect(regExpMatch('/\\w+@\\w+/', ' any string such as abc@gmail ')).toEqual('abc@gmail')
})
})

describe('traverseJson', () => {
Expand Down