diff --git a/spec/.eslintrc b/spec/.eslintrc
new file mode 100644
index 00000000..7bc296da
--- /dev/null
+++ b/spec/.eslintrc
@@ -0,0 +1,5 @@
+{
+ "env": {
+ "jest": true
+ }
+}
\ No newline at end of file
diff --git a/spec/unit/store/Login.spec.js b/spec/unit/store/Login.spec.js
index 6d398fbf..f32be094 100644
--- a/spec/unit/store/Login.spec.js
+++ b/spec/unit/store/Login.spec.js
@@ -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', () => {
diff --git a/spec/unit/utils/emojify.spec.js b/spec/unit/utils/emojify.spec.js
index 81ef584b..0ef34e16 100644
--- a/spec/unit/utils/emojify.spec.js
+++ b/spec/unit/utils/emojify.spec.js
@@ -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 '
)
})
@@ -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 , and '
)
})
@@ -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 , I love '
)
})
diff --git a/spec/unit/utils/suggestText.spec.js b/spec/unit/utils/suggestText.spec.js
index 918c80fd..0918c174 100644
--- a/spec/unit/utils/suggestText.spec.js
+++ b/spec/unit/utils/suggestText.spec.js
@@ -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)
})
})
})
diff --git a/spec/unit/utils/tootParser.spec.js b/spec/unit/utils/tootParser.spec.js
index 0c172ad4..d441b877 100644
--- a/spec/unit/utils/tootParser.spec.js
+++ b/spec/unit/utils/tootParser.spec.js
@@ -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')
})
})
})
diff --git a/spec/unit/utils/validator.spec.js b/spec/unit/utils/validator.spec.js
index b952c20d..8a6493c7 100644
--- a/spec/unit/utils/validator.spec.js
+++ b/spec/unit/utils/validator.spec.js
@@ -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)
})
})
})