Skip to content

Commit 54713ab

Browse files
committed
Disable tests when no config.
1 parent 0bb3f10 commit 54713ab

File tree

1 file changed

+72
-70
lines changed

1 file changed

+72
-70
lines changed

test.js

+72-70
Original file line numberDiff line numberDiff line change
@@ -9,87 +9,89 @@ const config = {
99
},
1010
}
1111

12-
console.log('Test file currently being run:', test.meta.file)
12+
if (config.chat.id !== '') {
13+
console.log('Test file currently being run:', test.meta.file)
1314

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',
15+
test('handle options.disabled = true', async (t) => {
16+
const pn = pnotice('pntest', {
17+
disabled: true,
18+
debug: true,
19+
chat: config.chat,
20+
env: 'test',
21+
})
22+
const response = await pn('hello world', 'INFO')
23+
t.is(response?.error?.title, 'Disabled')
2024
})
21-
const response = await pn('hello world', 'INFO')
22-
t.is(response?.error?.title, 'Disabled')
23-
})
2425

25-
test('handle options.chat.id = undefined', async (t) => {
26-
const pn = pnotice('pntest', {
27-
disabled: false,
28-
debug: true,
29-
chat: {
30-
id: undefined,
31-
secret: config.chat.secret,
32-
},
33-
env: 'test',
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+
const response = await pn('hello world', 'INFO')
37+
t.is(response?.error?.title, 'MissingChatId')
3438
})
35-
const response = await pn('hello world', 'INFO')
36-
t.is(response?.error?.title, 'MissingChatId')
37-
})
3839

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',
40+
test('handle options.chat.secret = undefined', async (t) => {
41+
const pn = pnotice('pntest', {
42+
disabled: false,
43+
debug: true,
44+
chat: {
45+
id: config.chat.id,
46+
secret: undefined,
47+
},
48+
env: 'test',
49+
})
50+
const response = await pn('hello world', 'INFO')
51+
t.is(response?.error?.title, 'MissingChatSecret')
4852
})
49-
const response = await pn('hello world', 'INFO')
50-
t.is(response?.error?.title, 'MissingChatSecret')
51-
})
5253

53-
test('handle options.chat = undefined', async (t) => {
54-
const pn = pnotice('pntest', {
55-
disabled: false,
56-
debug: true,
57-
chat: undefined,
58-
env: 'test',
54+
test('handle options.chat = undefined', async (t) => {
55+
const pn = pnotice('pntest', {
56+
disabled: false,
57+
debug: true,
58+
chat: undefined,
59+
env: 'test',
60+
})
61+
const response = await pn('hello world', 'INFO')
62+
t.is(response?.error?.title, 'MissingChatObject')
5963
})
60-
const response = await pn('hello world', 'INFO')
61-
t.is(response?.error?.title, 'MissingChatObject')
62-
})
6364

64-
test('handle text being an object', async (t) => {
65-
const pn = pnotice('pntest', {
66-
disabled: false,
67-
debug: true,
68-
chat: config.chat,
69-
env: 'test',
65+
test('handle text being an object', async (t) => {
66+
const pn = pnotice('pntest', {
67+
disabled: false,
68+
debug: true,
69+
chat: config.chat,
70+
env: 'test',
71+
})
72+
const response = await pn({ i: 'am an object' }, 'INFO')
73+
t.is(response?.error?.title, 'TextMustBeString')
7074
})
71-
const response = await pn({ i: 'am an object' }, 'INFO')
72-
t.is(response?.error?.title, 'TextMustBeString')
73-
})
7475

75-
test('handle namespace being an object', async (t) => {
76-
const pn = pnotice({ i: 'am an object' }, {
77-
disabled: false,
78-
debug: true,
79-
chat: config.chat,
80-
env: 'test',
76+
test('handle namespace being an object', async (t) => {
77+
const pn = pnotice({ i: 'am an object' }, {
78+
disabled: false,
79+
debug: true,
80+
chat: config.chat,
81+
env: 'test',
82+
})
83+
const response = await pn('hello world', 'INFO')
84+
t.is(response?.error?.title, 'NamespaceMustBeString')
8185
})
82-
const response = await pn('hello world', 'INFO')
83-
t.is(response?.error?.title, 'NamespaceMustBeString')
84-
})
8586

86-
test('handle successfully sent', async (t) => {
87-
const pn = pnotice('pntest', {
88-
disabled: false,
89-
debug: true,
90-
chat: config.chat,
91-
env: 'test',
87+
test('handle successfully sent', async (t) => {
88+
const pn = pnotice('pntest', {
89+
disabled: false,
90+
debug: true,
91+
chat: config.chat,
92+
env: 'test',
93+
})
94+
const response = await pn('hello world', 'INFO')
95+
t.is(response?.status, 'ok')
9296
})
93-
const response = await pn('hello world', 'INFO')
94-
t.is(response?.status, 'ok')
95-
})
97+
}

0 commit comments

Comments
 (0)