Skip to content

Commit f34595f

Browse files
nlfisaacs
authored andcommitted
tests: tests for birthday command
PR-URL: #1902 Credit: @nlf Close: #1902 Reviewed-by: @isaacs
1 parent d48086d commit f34595f

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

test/lib/birthday.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
const { test } = require('tap')
2+
const requireInject = require('require-inject')
3+
4+
test('birthday (nope)', (t) => {
5+
t.plan(1)
6+
const B = global[Buffer.from([66, 117, 102, 102, 101, 114])]
7+
const f = B.from([102, 114, 111, 109])
8+
const D = global[B[f]([68, 97, 116, 101])]
9+
const _6 = B[f]([98, 97, 115, 101, 54, 52]) + ''
10+
const l = B[f]('dG9TdHJpbmc=', _6)
11+
class FD extends D {
12+
[B[f]('Z2V0VVRDTW9udGg=', _6)[l]()] () {
13+
return 7
14+
}
15+
}
16+
global[B[f]([68, 97, 116, 101])] = FD
17+
const consoleLog = console.log
18+
console.log = () => undefined
19+
t.tearDown(() => {
20+
global[B[f]([68, 97, 116, 101])] = D
21+
console.log = consoleLog
22+
})
23+
const birthday = requireInject('../../lib/birthday', {})
24+
birthday([], (err) => {
25+
t.match(err, 'try again', 'not telling you the secret that easily are we?')
26+
})
27+
})
28+
29+
test('birthday (nope again)', (t) => {
30+
t.plan(1)
31+
const B = global[Buffer.from([66, 117, 102, 102, 101, 114])]
32+
const f = B.from([102, 114, 111, 109])
33+
const D = global[B[f]([68, 97, 116, 101])]
34+
const _6 = B[f]([98, 97, 115, 101, 54, 52]) + ''
35+
const l = B[f]('dG9TdHJpbmc=', _6)
36+
class FD extends D {
37+
[B[f]('Z2V0RnVsbFllYXI=', _6)[l]()] () {
38+
const d = new D()
39+
return d[B[f]('Z2V0RnVsbFllYXI=', _6)[l]()]() + 1
40+
}
41+
[B[f]('Z2V0VVRDTW9udGg=', _6)[l]()] () {
42+
return 9
43+
}
44+
}
45+
global[B[f]([68, 97, 116, 101])] = FD
46+
const consoleLog = console.log
47+
console.log = () => undefined
48+
t.tearDown(() => {
49+
global[B[f]([68, 97, 116, 101])] = D
50+
console.log = consoleLog
51+
})
52+
const birthday = requireInject('../../lib/birthday', {})
53+
birthday([], (err) => {
54+
t.match(err, 'try again', 'not telling you the secret that easily are we?')
55+
})
56+
})
57+
58+
test('birthday (yup)', (t) => {
59+
t.plan(1)
60+
const B = global[Buffer.from([66, 117, 102, 102, 101, 114])]
61+
const f = B.from([102, 114, 111, 109])
62+
const D = global[B[f]([68, 97, 116, 101])]
63+
const _6 = B[f]([98, 97, 115, 101, 54, 52]) + ''
64+
const l = B[f]('dG9TdHJpbmc=', _6)
65+
class FD extends D {
66+
[B[f]('Z2V0VVRDTW9udGg=', _6)[l]()] () {
67+
return 8
68+
}
69+
[B[f]('Z2V0VVRDRGF0ZQ==', _6)[l]()] () {
70+
return 29
71+
}
72+
}
73+
global[B[f]([68, 97, 116, 101])] = FD
74+
const consoleLog = console.log
75+
console.log = () => undefined
76+
t.tearDown(() => {
77+
global[B[f]([68, 97, 116, 101])] = D
78+
console.log = consoleLog
79+
})
80+
const birthday = requireInject('../../lib/birthday', {})
81+
birthday([], (err) => {
82+
t.ifError(err, 'npm birthday')
83+
})
84+
})

0 commit comments

Comments
 (0)