refs #209 Add eslint config for jest spec codes
This commit is contained in:
parent
473679be77
commit
fb429e4926
5
spec/.eslintrc
Normal file
5
spec/.eslintrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"env": {
|
||||
"jest": true
|
||||
}
|
||||
}
|
@ -29,17 +29,9 @@ describe('Login', () => {
|
||||
})
|
||||
|
||||
describe('actions', () => {
|
||||
let state
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
instances: [],
|
||||
selectedInstance: null,
|
||||
searching: false
|
||||
}
|
||||
})
|
||||
describe('fetchLogin', async () => {
|
||||
const commitMock = jest.fn()
|
||||
const url = await Login.actions.fetchLogin({ commit: commitMock }, 'pleroma.io')
|
||||
await Login.actions.fetchLogin({ commit: commitMock }, 'pleroma.io')
|
||||
expect(ipcRenderer.send).toHaveBeenCalledWith('get-auth-url', 'pleroma.io')
|
||||
})
|
||||
describe('pageBack', () => {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import assert from 'assert'
|
||||
import emojify from '@/utils/emojify'
|
||||
|
||||
describe('emojify', () => {
|
||||
@ -20,18 +19,14 @@ describe('emojify', () => {
|
||||
const str = 'I have a pen.'
|
||||
it('should not change', () => {
|
||||
const result = emojify(str, emoji)
|
||||
assert.strictEqual(
|
||||
result,
|
||||
str
|
||||
)
|
||||
expect(result).toEqual(str)
|
||||
})
|
||||
})
|
||||
describe('Contain a shortcode', () => {
|
||||
const str = 'I like :python:'
|
||||
it('should replace', () => {
|
||||
const result = emojify(str, emoji)
|
||||
assert.strictEqual(
|
||||
result,
|
||||
expect(result).toEqual(
|
||||
'I like <img draggable="false" class="emojione" alt="python" title="python" src="https://example.com/python" />'
|
||||
)
|
||||
})
|
||||
@ -40,8 +35,7 @@ describe('emojify', () => {
|
||||
const str = 'I like :python: , :nodejs: and :slack:'
|
||||
it('should replace', () => {
|
||||
const result = emojify(str, emoji)
|
||||
assert.strictEqual(
|
||||
result,
|
||||
expect(result).toEqual(
|
||||
'I like <img draggable="false" class="emojione" alt="python" title="python" src="https://example.com/python" /> , <img draggable="false" class="emojione" alt="nodejs" title="nodejs" src="https://example.com/nodejs" /> and <img draggable="false" class="emojione" alt="slack" title="slack" src="https://example.com/slack" />'
|
||||
)
|
||||
})
|
||||
@ -50,8 +44,7 @@ describe('emojify', () => {
|
||||
const str = 'I like :python: , I love :python:'
|
||||
it('should replace', () => {
|
||||
const result = emojify(str, emoji)
|
||||
assert.strictEqual(
|
||||
result,
|
||||
expect(result).toEqual(
|
||||
'I like <img draggable="false" class="emojione" alt="python" title="python" src="https://example.com/python" /> , I love <img draggable="false" class="emojione" alt="python" title="python" src="https://example.com/python" />'
|
||||
)
|
||||
})
|
||||
|
@ -1,4 +1,3 @@
|
||||
import assert from 'assert'
|
||||
import suggestText from '@/utils/suggestText'
|
||||
|
||||
describe('account', () => {
|
||||
@ -6,40 +5,40 @@ describe('account', () => {
|
||||
const str = '@h3pote'
|
||||
it('should match', () => {
|
||||
const [start, word] = suggestText(str, 7)
|
||||
assert.strictEqual(str, word)
|
||||
assert.strictEqual(start, 1)
|
||||
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)
|
||||
assert.strictEqual(word, '@h3pote')
|
||||
assert.strictEqual(start, 1)
|
||||
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)
|
||||
assert.strictEqual(word, '@h3pote')
|
||||
assert.strictEqual(start, 11)
|
||||
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)
|
||||
assert.strictEqual(word, '@h3pote')
|
||||
assert.strictEqual(start, 11)
|
||||
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)
|
||||
assert.strictEqual(word, null)
|
||||
assert.strictEqual(start, null)
|
||||
expect(word).toEqual(null)
|
||||
expect(start).toEqual(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,4 +1,3 @@
|
||||
import assert from 'assert'
|
||||
import { JSDOM } from 'jsdom'
|
||||
import { findLink, findTag, findAccount } from '@/utils/tootParser'
|
||||
|
||||
@ -16,7 +15,7 @@ I released Whalebird version 2.4.1. In version 2.4.0, Whalebird supports streami
|
||||
const target = doc.getElementById('link')
|
||||
it('should find', () => {
|
||||
const res = findLink(target)
|
||||
assert.strictEqual(res, 'https://github.com/h3poteto/whalebird-desktop/releases/tag/2.4.1')
|
||||
expect(res).toEqual('https://github.com/h3poteto/whalebird-desktop/releases/tag/2.4.1')
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -34,7 +33,7 @@ I released Whalebird version 2.4.1. In version 2.4.0, Whalebird supports streami
|
||||
const target = doc.getElementById('tag')
|
||||
it('should find', () => {
|
||||
const res = findTag(target)
|
||||
assert.strictEqual(res, 'whalebird')
|
||||
expect(res).toEqual('whalebird')
|
||||
})
|
||||
})
|
||||
|
||||
@ -50,7 +49,7 @@ I released Whalebird version 2.4.1. In version 2.4.0, Whalebird supports streami
|
||||
const target = doc.getElementById('tag')
|
||||
it('should find', () => {
|
||||
const res = findTag(target)
|
||||
assert.strictEqual(res, 'whalebird')
|
||||
expect(res).toEqual('whalebird')
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -67,8 +66,8 @@ describe('findAccount', () => {
|
||||
const target = doc.getElementById('user')
|
||||
it('should find', () => {
|
||||
const res = findAccount(target)
|
||||
assert.strictEqual(res.username, '@h3_poteto')
|
||||
assert.strictEqual(res.acct, '@h3_poteto@social.mikutter.hachune.net')
|
||||
expect(res.username).toEqual('@h3_poteto')
|
||||
expect(res.acct).toEqual('@h3_poteto@social.mikutter.hachune.net')
|
||||
})
|
||||
})
|
||||
|
||||
@ -82,8 +81,8 @@ describe('findAccount', () => {
|
||||
const target = doc.getElementById('user')
|
||||
it('should find', () => {
|
||||
const res = findAccount(target)
|
||||
assert.strictEqual(res.username, '@h3poteto')
|
||||
assert.strictEqual(res.acct, '@h3poteto@pleroma.io')
|
||||
expect(res.username).toEqual('@h3poteto')
|
||||
expect(res.acct).toEqual('@h3poteto@pleroma.io')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -1,4 +1,3 @@
|
||||
import assert from 'assert'
|
||||
import { domainFormat } from '@/utils/validator'
|
||||
|
||||
describe('validator', () => {
|
||||
@ -7,56 +6,56 @@ describe('validator', () => {
|
||||
const domain = 'https://mastodon.social'
|
||||
it('should not match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, -1)
|
||||
expect(res).toEqual(-1)
|
||||
})
|
||||
})
|
||||
describe('string contains account name', () => {
|
||||
const domain = 'h3_poteto@mastodon.social'
|
||||
it('should not match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, -1)
|
||||
expect(res).toEqual(-1)
|
||||
})
|
||||
})
|
||||
describe('string is gTLD domain', () => {
|
||||
const domain = 'mastodon.social'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, 0)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
describe('string is subdomain', () => {
|
||||
const domain = 'music.mastodon.social'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, 0)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
describe('string is subdomain', () => {
|
||||
const domain = 'social.tchncs.de'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, 0)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
describe('string is jp domain', () => {
|
||||
const domain = 'mstdn.co.jp'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, 0)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
describe('string contains hyphone', () => {
|
||||
const domain = 'music-mastodon.social'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, 0)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
describe('string is short domain', () => {
|
||||
const domain = 'id.cc'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
assert.strictEqual(res, 0)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user