2022-11-15 11:36:54 +03:00
|
|
|
import { describe, it, expect } from 'vitest'
|
2023-01-24 19:10:59 +03:00
|
|
|
import { splitByUrl } from '@/helpers'
|
2022-10-16 20:08:36 +03:00
|
|
|
|
|
|
|
describe('Helpers', () => {
|
|
|
|
describe('splitByUrl()', () => {
|
|
|
|
it('should not split anything', () => {
|
|
|
|
expect(splitByUrl('test')).toEqual(['test'])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should split to array if http/https is found', () => {
|
|
|
|
expect(splitByUrl('test http://test.something')).toEqual(['test ', 'http://test.something'])
|
|
|
|
expect(splitByUrl('123456 test@345 https://something.else test@@!!#789')).toEqual(['123456 test@345 ', 'https://something.else', ' test@@!!#789'])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should split to array if www is found', () => {
|
|
|
|
expect(splitByUrl('test www.test.something')).toEqual(['test ', 'www.test.something'])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should split to array where both www and http/https are found', () => {
|
|
|
|
expect(splitByUrl('test http://www.test.something')).toEqual(['test ', 'http://www.test.something'])
|
|
|
|
expect(splitByUrl('test https://www.something.else')).toEqual(['test ', 'https://www.something.else'])
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should split correctly if more than one url exists', () => {
|
2022-11-15 11:36:54 +03:00
|
|
|
expect(splitByUrl('test http://www.test.something some string and https://onemoreurl.com')).toEqual([
|
|
|
|
'test ',
|
|
|
|
'http://www.test.something',
|
|
|
|
' some string and ',
|
|
|
|
'https://onemoreurl.com'
|
|
|
|
])
|
2022-10-16 20:08:36 +03:00
|
|
|
})
|
|
|
|
})
|
2022-11-15 11:36:54 +03:00
|
|
|
})
|