Skip to content

Commit 5688599

Browse files
committed
0.2.0
1 parent c9ebcb7 commit 5688599

File tree

3 files changed

+92
-4
lines changed

3 files changed

+92
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.6",
2+
"version": "0.2.0",
33
"name": "pushnotice",
44
"description": "Application Notifications sent to Telegram. Linking pushnotice.chat into your project.",
55
"keywords": [
@@ -10,13 +10,13 @@
1010
"logging"
1111
],
1212
"license": "ISC",
13-
"main": "index.js",
13+
"main": "index.mjs",
1414
"scripts": {
1515
"test": "xo && ava -v",
1616
"ava": "ava -v --watch"
1717
},
1818
"files": [
19-
"index.js"
19+
"index.mjs"
2020
],
2121
"author": {
2222
"name": "Chris Spiegl",

test.js

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
const test = require('ava')
2+
const pnotice = require('.')
3+
4+
// TODO: must be placed outside of this file and not commited to the repo!
5+
const config = {
6+
chat: {
7+
id: 'xXxXxXxXxXx',
8+
secret: 'xXxXxXxXxXx',
9+
},
10+
}
11+
12+
console.log('Test file currently being run:', test.meta.file)
13+
14+
test('handle options.disabled = true', async (t) => {
15+
const pn = pnotice('pntest', {
16+
disabled: true,
17+
debug: true,
18+
chat: config.chat,
19+
env: 'test',
20+
})
21+
t.is((await pn('hello world', 'INFO'))?.error?.title, 'Disabled')
22+
})
23+
24+
test('handle options.chat.id = undefined', async (t) => {
25+
const pn = pnotice('pntest', {
26+
disabled: false,
27+
debug: true,
28+
chat: {
29+
id: undefined,
30+
secret: config.chat.secret,
31+
},
32+
env: 'test',
33+
})
34+
t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatId')
35+
})
36+
37+
test('handle options.chat.secret = undefined', async (t) => {
38+
const pn = pnotice('pntest', {
39+
disabled: false,
40+
debug: true,
41+
chat: {
42+
id: config.chat.id,
43+
secret: undefined,
44+
},
45+
env: 'test',
46+
})
47+
t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatSecret')
48+
})
49+
50+
test('handle options.chat = undefined', async (t) => {
51+
const pn = pnotice('pntest', {
52+
disabled: false,
53+
debug: true,
54+
chat: undefined,
55+
env: 'test',
56+
})
57+
t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatObject')
58+
})
59+
60+
test('handle text being an object', async (t) => {
61+
const pn = pnotice('pntest', {
62+
disabled: false,
63+
debug: true,
64+
chat: config.chat,
65+
env: 'test',
66+
})
67+
t.is((await pn({ i: 'am an object' }, 'INFO'))?.error?.title, 'TextMustBeString')
68+
})
69+
70+
test('handle namespace being an object', async (t) => {
71+
const pn = pnotice({ i: 'am an object' }, {
72+
disabled: false,
73+
debug: true,
74+
chat: config.chat,
75+
env: 'test',
76+
})
77+
t.is((await pn('hello world', 'INFO'))?.error?.title, 'NamespaceMustBeString')
78+
})
79+
80+
test('handle successfully sent', async (t) => {
81+
const pn = pnotice('pntest', {
82+
disabled: false,
83+
debug: true,
84+
chat: config.chat,
85+
env: 'test',
86+
})
87+
t.is((await pn('hello world', 'INFO'))?.success, true)
88+
})

0 commit comments

Comments
 (0)