|
1 |
| -const test = require('ava') |
2 |
| -const pnotice = require('.') |
3 |
| - |
4 |
| -// TODO: find a way to load config.chat from file? |
5 |
| - |
6 |
| -const config = { |
7 |
| - chat: { |
8 |
| - id: '21614670', |
9 |
| - secret: '37be8b95538a70eb8a08e56c945f38e6dad50bfc', |
10 |
| - }, |
11 |
| -} |
12 |
| - |
13 |
| - |
14 |
| -console.log('Test file currently being run:', test.meta.file) |
15 |
| - |
16 |
| -test('handle options.disabled = true', async (t) => { |
17 |
| - const pn = pnotice('pntest', { |
18 |
| - disabled: true, |
19 |
| - debug: true, |
20 |
| - chat: config.chat, |
21 |
| - env: 'test', |
22 |
| - }) |
23 |
| - t.is((await pn('hello world', 'INFO'))?.error?.title, 'Disabled') |
24 |
| -}) |
25 |
| - |
26 |
| -test('handle options.chat.id = undefined', async (t) => { |
27 |
| - const pn = pnotice('pntest', { |
28 |
| - disabled: false, |
29 |
| - debug: true, |
30 |
| - chat: { |
31 |
| - id: undefined, |
32 |
| - secret: config.chat.secret, |
33 |
| - }, |
34 |
| - env: 'test', |
35 |
| - }) |
36 |
| - t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatId') |
37 |
| -}) |
38 |
| - |
39 |
| -test('handle options.chat.secret = undefined', async (t) => { |
40 |
| - const pn = pnotice('pntest', { |
41 |
| - disabled: false, |
42 |
| - debug: true, |
43 |
| - chat: { |
44 |
| - id: config.chat.id, |
45 |
| - secret: undefined, |
46 |
| - }, |
47 |
| - env: 'test', |
48 |
| - }) |
49 |
| - t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatSecret') |
50 |
| -}) |
51 |
| - |
52 |
| -test('handle options.chat = undefined', async (t) => { |
53 |
| - const pn = pnotice('pntest', { |
54 |
| - disabled: false, |
55 |
| - debug: true, |
56 |
| - chat: undefined, |
57 |
| - env: 'test', |
58 |
| - }) |
59 |
| - t.is((await pn('hello world', 'INFO'))?.error?.title, 'MissingChatObject') |
60 |
| -}) |
61 |
| - |
62 |
| -test('handle text being an object', async (t) => { |
63 |
| - const pn = pnotice('pntest', { |
64 |
| - disabled: false, |
65 |
| - debug: true, |
66 |
| - chat: config.chat, |
67 |
| - env: 'test', |
68 |
| - }) |
69 |
| - t.is((await pn({ i: 'am an object' }, 'INFO'))?.error?.title, 'TextMustBeString') |
70 |
| -}) |
71 |
| - |
72 |
| -test('handle namespace being an object', async (t) => { |
73 |
| - const pn = pnotice({ i: 'am an object' }, { |
74 |
| - disabled: false, |
75 |
| - debug: true, |
76 |
| - chat: config.chat, |
77 |
| - env: 'test', |
78 |
| - }) |
79 |
| - t.is((await pn('hello world', 'INFO'))?.error?.title, 'NamespaceMustBeString') |
80 |
| -}) |
81 |
| - |
82 |
| -test('handle successfully sent', async (t) => { |
83 |
| - const pn = pnotice('pntest', { |
84 |
| - disabled: false, |
85 |
| - debug: true, |
86 |
| - chat: config.chat, |
87 |
| - env: 'test', |
88 |
| - }) |
89 |
| - t.is((await pn('hello world', 'INFO'))?.success, true) |
90 |
| -}) |
91 |
| -const test = require('ava') |
92 |
| -const pnotice = require('.') |
| 1 | +import test from 'ava' |
| 2 | +import pnotice from '.' |
93 | 3 |
|
94 | 4 | // TODO: find a way to load config.chat from file?
|
95 | 5 |
|
|
0 commit comments