1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2024-12-08 15:06:53 +01:00
Whalebird-desktop-client-ma.../spec/renderer/unit/utils/suggestText.spec.ts
2019-03-25 21:51:24 +09:00

45 lines
1.2 KiB
TypeScript

import suggestText from '@/utils/suggestText'
describe('account', () => {
describe('Only account name', () => {
const str = '@h3pote'
it('should match', () => {
const [start, word] = suggestText(str, 7)
expect(str).toEqual(word)
expect(start).toEqual(1)
})
})
describe('Beginning of the sentence', () => {
const str = '@h3pote toot body'
it('should match', () => {
const [start, word] = suggestText(str, 7)
expect(word).toEqual('@h3pote')
expect(start).toEqual(1)
})
})
describe('Halfway of the sentence', () => {
const str = 'toot body @h3pote toot'
it('should match', () => {
const [start, word] = suggestText(str, 17)
expect(word).toEqual('@h3pote')
expect(start).toEqual(11)
})
})
describe('End of the sentence', () => {
const str = 'toot body @h3pote'
it('should match', () => {
const [start, word] = suggestText(str, 17)
expect(word).toEqual('@h3pote')
expect(start).toEqual(11)
})
})
describe('No space', () => {
const str = 'tootbody@h3pote'
it('should not match', () => {
const [start, word] = suggestText(str, 15)
expect(word).toEqual(null)
expect(start).toEqual(null)
})
})
})