Skip to content

Commit 361faf3

Browse files
committed
Make test conform to new xo file.
1 parent 2b00720 commit 361faf3

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.xo-config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
'error',
1919
"never",
2020
{
21+
'js': 'always',
2122
'json': "always",
2223
'vue': "always",
2324
'css': 'always',
@@ -29,6 +30,7 @@ module.exports = {
2930
"never",
3031
{
3132
"tryExtensions": [".js", ".json"],
33+
'.js': 'always',
3234
'.json': "always",
3335
'.vue': "always",
3436
'.css': 'always',

test.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import test from 'ava'
2-
import pnotice from '.'
2+
import pnotice from './index.js'
33

44
// TODO: find a way to load config.chat from file?
5+
const config = {
6+
chat: {
7+
id: '',
8+
secret: '',
9+
},
10+
}
511

612
console.log('Test file currently being run:', test.meta.file)
713

@@ -12,7 +18,8 @@ test('handle options.disabled = true', async (t) => {
1218
chat: config.chat,
1319
env: 'test',
1420
})
15-
t.is((await pn('hello world', 'INFO'))?.error?.title, 'Disabled')
21+
const response = await pn('hello world', 'INFO')
22+
t.is(response?.error?.title, 'Disabled')
1623
})
1724

1825
test('handle options.chat.id = undefined', async (t) => {
@@ -25,7 +32,8 @@ test('handle options.chat.id = undefined', async (t) => {
2532
},
2633
env: 'test',
2734
})
28-
t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatId')
35+
const response = await pn('hello world', 'INFO')
36+
t.is(response?.error?.title, 'MissingChatId')
2937
})
3038

3139
test('handle options.chat.secret = undefined', async (t) => {
@@ -38,7 +46,8 @@ test('handle options.chat.secret = undefined', async (t) => {
3846
},
3947
env: 'test',
4048
})
41-
t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatSecret')
49+
const response = await pn('hello world', 'INFO')
50+
t.is(response?.error?.title, 'MissingChatSecret')
4251
})
4352

4453
test('handle options.chat = undefined', async (t) => {
@@ -48,7 +57,8 @@ test('handle options.chat = undefined', async (t) => {
4857
chat: undefined,
4958
env: 'test',
5059
})
51-
t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatObject')
60+
const response = await pn('hello world', 'INFO')
61+
t.is(response?.error?.title, 'MissingChatObject')
5262
})
5363

5464
test('handle text being an object', async (t) => {
@@ -58,7 +68,8 @@ test('handle text being an object', async (t) => {
5868
chat: config.chat,
5969
env: 'test',
6070
})
61-
t.is((await pn({ i: 'am an object' }, 'INFO'))?.error?.title, 'TextMustBeString')
71+
const response = await pn({ i: 'am an object' }, 'INFO')
72+
t.is(response?.error?.title, 'TextMustBeString')
6273
})
6374

6475
test('handle namespace being an object', async (t) => {
@@ -68,7 +79,8 @@ test('handle namespace being an object', async (t) => {
6879
chat: config.chat,
6980
env: 'test',
7081
})
71-
t.is((await pn('hello world', 'INFO'))?.error?.title, 'NamespaceMustBeString')
82+
const response = await pn('hello world', 'INFO')
83+
t.is(response?.error?.title, 'NamespaceMustBeString')
7284
})
7385

7486
test('handle successfully sent', async (t) => {
@@ -78,5 +90,6 @@ test('handle successfully sent', async (t) => {
7890
chat: config.chat,
7991
env: 'test',
8092
})
81-
t.is((await pn('hello world', 'INFO'))?.success, true)
93+
const response = await pn('hello world', 'INFO')
94+
t.is(response?.status, 'ok')
8295
})

0 commit comments

Comments
 (0)